首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

整合ssh2时出现 404

2012-02-04 
整合ssh2时出现 404 - There is no Action mapped for namespace / and action name login.错误HTTP Statu

整合ssh2时出现 404 - There is no Action mapped for namespace / and action name login.
错误
HTTP Status 404 - There is no Action mapped for namespace / and action name login.

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

type Status report

message There is no Action mapped for namespace / and action name login.

description The requested resource (There is no Action mapped for namespace / and action name login.) is not available.


web.xml

XML code
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5"    xmlns="http://java.sun.com/xml/ns/javaee"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">   <context-param>        <param-name>contextConfigLocation</param-name>        <param-value>/applicationContext.xml</param-value>    </context-param>    <listener>        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>    </listener>    <welcome-file-list>        <welcome-file>index.jsp</welcome-file>    </welcome-file-list>       <filter>        <filter-name>struts2</filter-name>        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>    </filter>    <filter-mapping>        <filter-name>struts2</filter-name>        <url-pattern>/*</url-pattern>    </filter-mapping></web-app>




struts.xml
XML code
<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd"><struts>    <package name="common" extends="struts-default">        <action name="login" class="userAction" method="login">            <result name="success">/success.jsp</result>            <result name="input">/error.jsp</result>        </action>    </package></struts>



applicationContext.xml
XML code
<?xml version="1.0" encoding="UTF-8"?><beans    xmlns="http://www.springframework.org/schema/beans"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xmlns:p="http://www.springframework.org/schema/p"    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">    <bean id="dataSource"        class="org.springframework.jdbc.datasource.DriverManagerDataSource">        <property name="driverClassName">            <value>com.mysql.jdbc.Driver</value>        </property>        <property name="url">            <value>jdbc:mysql://127.0.0.1:3306/teaching_affair</value>        </property>        <property name="username">            <value>root</value>        </property>        <property name="password">            <value>root</value>        </property>    </bean>    <bean id="sessionFactory"        class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">        <property name="dataSource"            ref="dataSource">        </property>        <property name="hibernateProperties">            <value>                hibernate.dialect=org.hibernate.dialect.MySQLDialect                hibernate.hbm2ddl.auto=update                hibernate.show_sql=true                hibernate.format_sql=false            </value>        </property>        <property name="mappingResources">            <list>                <value>bean/Userinfo.hbm.xml</value>            </list>        </property>    </bean>       <bean id="transactionManager"        class="org.springframework.orm.hibernate3.HibernateTransactionManager">        <property name="sessionFactory" ref="sessionFactory"/>    </bean>        <bean id="userDao" class="com.sshtest.dao.UserDaoImple">        <property name="sessionFactory" ref="sessionFactory"/>    </bean>       <bean id="userService" class="com.sshtest.service.UserServiceImple">        <property name="userDao" ref="userDao"/>    </bean>       <bean id="userAction" class="com.sshtest.action.UserAction">        <property name="userService" ref="userService"/>    </bean></beans> 




index.jsp
HTML code
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html>  <head>    <base href="<%=basePath%>">       <title>My JSP 'index.jsp' starting page</title>    <meta http-equiv="pragma" content="no-cache">    <meta http-equiv="cache-control" content="no-cache">    <meta http-equiv="expires" content="0">       <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">    <meta http-equiv="description" content="This is my page">    <!--    <link rel="stylesheet" type="text/css" href="styles.css">    -->  </head>   <body>    <form action="login.action" method="post"><table>        <tr><td>username:</td><td><input type="text" name="user.username"/></td></tr>        <tr><td>password:</td><td><input type="password" name="user.password"/></td></tr>        <tr><td><input type="submit" value="login"/></td></tr>    </table></form>  </body></html>


[解决办法]
你的JSP页面form提交时中也要加:namespace="/common"

热点排行