struts爆404错误怎么解决?
错误
HTTP Status 404 -
--------------------------------------------
type Status report
message
description The requested resource is not available.
--------------------------------------------
Apache Tomcat/6.0.36
<?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">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!--
==================================================================servlet配置
-->
<servlet>
<!-- 给你的servlet取名,任意的 -->
<servlet-name>login</servlet-name>
<!-- 指明servlet的路径(包名+类名 -->
<servlet-class>com.xunfang.em_mallServer.Login</servlet-class>
</servlet>
<servlet-mapping>
<!-- 这个servlet名必须和映射的一致 -->
<servlet-name>login</servlet-name>
<!-- 这是在浏览器中输入的访问该servlet的url -->
<url-pattern>/login</url-pattern>
</servlet-mapping>
<!--
================================================================struts配置
-->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
<?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><!-- struts配置 -->
<package name="struts2" extends="struts-default" namespace="/">
<action name="login" class="com.xunfang.em_mallServer.action.LoginAction">
<result name="success">/main.jsp</result>
<result name="failer">/login.jsp</result>
</action>
</package>
</struts>
package com.xunfang.em_mallServer.action;
import com.opensymphony.xwork2.ActionSupport;
/**
* @description 登陆验证的action
* @author Administrator
*
*/
public class LoginAction extends ActionSupport {
/**
*
*/
private static final long serialVersionUID = -3737838411350455273L;
private String username;
private String password;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
// 此处验证用户必须等hello 密码登录word才会返回成功页面。当然,真实开发中肯定不会这样写,这里只是做一个模拟。
public String execute() throws Exception {
if ("admin".equals(this.getUsername().trim())
&& "admin".equals(this.getPassword().trim())) {
return "success";
} else {
this.addFieldError("username", "usernmae or password error");
return "failer";
}
}
// 下面内容判断用户名不能为空
@Override
public void validate() {
if (null == this.getUsername() || "".equals(this.getUsername().trim())) {
this.addFieldError("username", "username error");
}
if (null == this.getPassword() || "".equals(this.getPassword().trim())) {
this.addFieldError("password", "password error");
}
}
}