Struts + tomcat 5出现在奇怪问题

onlinb41 2007-01-21 06:26:53
初学struts,在调第一个小应用时,首页可以正常显示,当点提交时出现如下错误:
HTTP Status 404 - Servlet action is not available

type Status report

message Servlet action is not available

description The requested resource (Servlet action is not available) is not available.
----------------------------------------------------------------

以下为web.xml文件:
<?xml version="1.0" encoding="ISO-8859-1" ?>

<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
version="2.4">

<icon></icon>
<display-name>Struts Base Application</display-name>
<description>Struts Base Application</description>

<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>

---------------------------------------------------------------

以下为struts-config.xml:
<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

<struts-config>
<form-beans>

<form-bean name="testForm"
type="org.apache.struts.validator.DynaValidatorForm">
<form-property name="name" type="java.lang.String"/>
<form-property name="comments" type="java.lang.String"/>
</form-bean>

</form-beans>

<action-mappings>
<action path="/test"
type="com.wrox.begjsp.ch19.struts.TestAction"
name="testForm"
validate="true"
input="/index.jsp"
scope="request">
<forward name="success" path="/details.jsp"/>
</action>
</action-mappings>

<message-resources parameter="messages" null="false"/>

<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames"
value="/WEB-INF/validator-rules.xml,
/WEB-INF/validation.xml"/>
</plug-in>

</struts-config>

-----------------------------------------------------------------------

以下是index.jsp代码:
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html>
<head>
<title><bean:message key="form.title"/></title>
</head>
<body>

<h1><bean:message key="form.title"/></h1>
<h3>what will showed this time?</h3>

<center>
<html:form action="/test" method="POST">
<table width="350" border="0" cellpadding="3" cellspacing="0">
<logic:messagesPresent message="false">
<tr>
<td colspan=2><b><bean:message key="errors.global"/></b></td>
</tr>
</logic:messagesPresent>
<logic:messagesPresent property="name">
<tr>
<td colspan=2><html:errors property="name"/></td>
</tr>
</logic:messagesPresent>
<tr>
<td><bean:message key="form.name.title"/></td>
<td><html:text altKey="form.name.title" property="name" size="30"/></td>
</tr>
<tr>
<td valign="top"><bean:message key="form.comments.title"/></td>
<td>
<html:textarea property="comments" cols="30" rows="8"></html:textarea>
</td>
</tr>
<tr>
<td> </td>
<td align="center"><html:submit/></td>
</tr>
</table>
</html:form>
</center>
</body>
</html>
-------------------------------------------------------------
index.jsp可以正常显示,在输入数据后,点"提交",就会出现错误.浏览器地址显示为:
http://localhost:8080/struts-base/test.do(地址正确)

谢了先~~~~
...全文
210 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
xielituo 2007-01-25
  • 打赏
  • 举报
回复
给点建议,互相学习
1、看看你的action是不是继承而来,或者是不是继承错对象了;
2、JAR包是不是少了;
3、struts-config.xml是否放在WEB-INF目录下;
4、你的Form是直接指向了org.apache.struts.validator.DynaValidatorForm。
那你在jsp中元素肯定不会有GETTER方法,建议从DynaValidatorForm继承出一个新类包含你表单中需要的元素;
Augustans 2007-01-25
  • 打赏
  • 举报
回复
看看你的struts的jar包是不是都在lib下面。
zhangyin106806419 2007-01-25
  • 打赏
  • 举报
回复
这个问题解决了吗?和我遇到的一样~有哪个大哥来指点一下
wanzyqyy 2007-01-21
  • 打赏
  • 举报
回复
404错误是没有找到指定的JSP文件~
onlinb41 2007-01-21
  • 打赏
  • 举报
回复
试了,没用.跟没改之前一样的错误.
mliwng 2007-01-21
  • 打赏
  • 举报
回复
<html:form action="/test" method="POST">
改成
<html:form action="/test.do" method="POST">
试试
onlinb41 2007-01-21
  • 打赏
  • 举报
回复
到google和baidu里,有很多朋友都遇过此类问题,但并没有很好的解决.也试了很多方法,都不能成功,希望大家帮忙看看!~~~

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧