初学Struts2 被无限404折腾两夜了 求拯救
更希望有人能教教我怎么追踪解决这种问题 给满100分 希望有人肯指教
情况是访问任何页面都是404
去掉web.xml flicker元素正常
环境:eclipse for javaee
tomcat 7.0
struts 2.3.4
web.xml配置:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>Struts2Dome</display-name>
<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="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<!-- <constant name="struts.custom.il8n.resources" value="mess"></constant>
<constant name="struts.il8n.encoding" value="UTF-8"></constant> -->
<package name="liu" extends = "struts-default">
<action name = "login" class = "liu.LoginAction">
<result name = "input">/login.jsp</result>
<result name = "error">/error.jsp</result>
<result name = "succeed">/welcome.jsp</result>
</action>
</package>
</struts>
login.jsp:
<?xml version="1.0" encoding="UTF-8" ?>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ 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>dsdds</title>
</head>
<body>
<form action = "login" method = "post">
<%-- <textfield name = "username" key = "username" />
<textfield name = "password" key = "password" />
<submit key = "login" /> --%>
</form>
</body>
</html>
LoginAction.java :
package liu;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class LoginAction extends ActionSupport{
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;
}
public String execute() throws Exception
{
if(getUsername().equals("liu") && getPassword().equals("liu"))
{
ActionContext.getContext().getSession().put("user", getUsername());