日期:2014-05-17  浏览次数:20895 次

struts2 错误404 怎么办呢
我写了一个struts2 例子,可是错误404 谁帮我看看啊 为什么
访问地址http://localhost:8080/struts2/login.jsp 
login.jsp 文件代码如下
Java code

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

<html>
<head>
<title>登陆页面</title>

</head>
<body>
  <s:action name="tag1" executeResult="true"/>
</body>
</html>


web.xml文件代码如下
Java code
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_9" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

    <display-name>Struts Blank</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代码如下
Java code
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>

    <constant name="struts.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="true" />

    <package name="lee" namespace="/" extends="struts-default">

        <action name="tag1" class="lee.TagAction">
        <result name="done">welcome.jsp</result>
        </action>
         <action name="tag2" class="lee.TagAction" method=“login”>
        <result name="done">error.jsp</result>
        </action>
     
    </package>
    
</struts>


src/lee/TagAction一个类 代码如下
Java code
package lee;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

public class TagAction extends  ActionSupport{
private String author;

public String getAuthor() {
    return author;
}

public void setAuthor(String author) {
    this.author = author;
}
public String execute() throws Exception
{
    return "done";
}
public String login() throws Exception
{
    ServletActionContext.getRequest().setAttribute("author", getAuthor());
    return "done";
}
}



------解决方案--------------------
给个主要错误信息看看