您的位置:首页 > 大数据 > 人工智能

烦人的错误HTTP Status 404 - Servlet action is not available

2009-05-05 00:27 495 查看
环境是myeclipse+tomcat5.5+mysql; struts1.2+spring2.5+hibernate3.2
为了测试环境我只建立了一个简单的user表

输入后点击提交然后出现HTTP Status 404 - Servlet action is not available,

index.jsp页面
(用的是myeclipse自带的web browser)





以下为index.jsp的代码


<html>
<head>
<title>JSP for UserForm form</title>
</head>
<body>
<html:form action="/user">
password : <html:password property="password"/><br/>
username : <html:text property="username"/><br/>
<html:submit/><html:cancel/>
</html:form>
</body>
</html>


当单击Submit后出现以下错误



以下是ApplicationContext.xml. struts-config.xml. web.xml三个配置文件的内容,在网上搜了一下解决方案,大多是针对这三个配置文件来说的。请各位看看到底是哪块导致HTTP Status 404 - Servlet action is not available。

1.ApplicationContext.xml配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
<bean id="dataSource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="org.gjt.mm.mysql.Driver">
</property>
<property name="url"
value="jdbc:mysql://localhost:3306/salemodel">
</property>
<property name="username" value="root"></property>
<property name="password" value="root"></property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>org/saleModel/vo/User.hbm.xml</value></list>
</property></bean>
<bean id="userDAO" class="org.saleModel.dao.UserDAO">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="userService" class="org.saleModel.service.UserService"
abstract="false" lazy-init="default" autowire="default"
dependency-check="default">
<property name="userDAO">
<ref local="userDAO" />
</property>
</bean>
<bean name="/user" class="org.saleModel.struts.action.UserAction"
abstract="false" lazy-init="default" autowire="default"
dependency-check="default">
<property name="userService">
<ref local="userService" />
</property>
</bean></beans>

2.struts配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">
<struts-config>
<data-sources />
<form-beans >
<form-bean name="userForm" type="org.saleModel.struts.form.UserForm" />//表单类
</form-beans>
<global-exceptions />
<global-forwards />
<action-mappings >
//........................................... action类的配置
<action
attribute="userForm"
input="/jsp/index.jsp"
name="userForm"
path="/user"
scope="request"
>
<forward name="success" path="/jsp/success.jsp" />
<forward name="failure" path="/jsp/index.jsp" />
</action>
//......................................................................

</action-mappings>
//....................................... 控制器的配置
<controller>
<set-property property="processorClass" value="org.springframework.web.struts.DelegatingRequestProcessor"/>
</controller>
//............................................
<message-resources parameter="org.saleModel.struts.ApplicationResources" />

//.............................配置spring插件...................
<plug-in className="org.springframework.web.struts.contextLocationPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml"/>
</plug-in>
//............................
</struts-config>
3.web.xml配置文件如下:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.5" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

<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>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>

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

//......................
</servlet-mapping>

//.........................................
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>

4.我的工程目录如下:



试过了一些网上给出的解决方案,但是还是解决不了所以想请高人帮助下~~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: