日期:2014-05-18  浏览次数:20636 次

登录例子的404错误
简单的struts2+spring的登录例子,输入账户密码点击登录后显示404错误,搞了半天了。求帮忙!

web.xml:
<?xml version="1.0" encoding="GBK"?>
<web-app 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_3_0.xsd" version="3.0">

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

<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 version="1.0" encoding="GBK"?>
<!-- 指定Struts 2配置文件的DTD信息 -->
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.1.7//EN"
"http://struts.apache.org/dtds/struts-2.1.7.dtd">
<!-- Struts 2配置文件的根元素 -->
<struts>

<constant name="struts.i18n.encoding" value="GBK"/>
<constant name="struts.devMode" value="true"/>
<package name="lee" extends="struts-default">

<action name="loginPro" class="loginAction">

<result name="error">/WEB-INF/content/error.jsp</result>
<result name="success">/WEB-INF/content/welcome.jsp</result>
</action>

<action name="*">
<result>/WEB-INF/content/{1}.jsp</result>
</action>
</package>
</struts>

login.jsp:
<%@ page contentType="text/html; charset=GBK" language="java" errorPage="" %>
<%@taglib prefix="s" uri="/struts-tags"%>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>登录页面</title>
</head>
<body>
<h3>用户登录</h3>
<s:form action="loginPro">
<s:textfield name="username" label="用户名"/>
<s:textfield name="password" label="密码"/>
<tr align="center">
<td colspan="2">
<s:submit value="登录" theme="simple"/>
<s:reset value="重设" theme="simple"/>
</td>
</tr>
</s:form>
</body>
</html>

loginAction.java:
package org.crazyit.app.action;

import com.opensymphony.xwork2.Action;

import org.crazyit.app.service.*;

public class LoginAction
implements Action
{
//下面是用于封装用户请求参数的两个属性
private String username;
private String password;
//用于封装处理结果的属性
private String tip;
//系统所用的业务逻辑组件
private MyService ms;
//设置注入业务逻辑组件所必需的setter方法
public voi