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

struts2 @action报错404
java方法:
@Action(value = "/test/init", results = {@Result(name = "init", location = "/index.jsp") })
public String init() {
System.out.println("11111111");
System.out.println("22222222");
System.out.println("33333333");
System.out.println("44444444");
Map<String, String> map = testService.getSysdate();
request.setAttribute("sysdate", map.get("SYSDATE"));
return "init";
}

struts.xml配置:
<!-- 请求参数的编码方式 -->  
     <constant name="struts.i18n.encoding" value="UTF-8"/>  
<constant name="struts.convention.action.suffix" value="Action" />
<constant name="struts.convention.action.mapAllMatches" value="true" />
    <!-- 指定被struts2处理的请求后缀类型。多个用逗号隔开 -->  
    <constant name="struts.action.extension" value="action,do,htm"/>  
    <!-- 当struts.xml改动后,是否重新加载。默认值为false(生产环境下使用),开发阶段最好打开  -->  
    <constant name="struts.configuration.xml.reload" value="true"/>  
    <!-- 是否使用struts的开发模式。开发模式会有更多的调试信息。默认值为false(生产环境下使用),开发阶段最好打开  -->  
    <constant name="struts.devMode" value="false"/>    
    <!-- 设置浏览器是否缓存静态内容。默认值为true(生产环境下使用),开发阶段最好关闭  -->  
    <constant name="struts.serve.static.browserCache" value="false" />  
    <!-- 指定由spring负责action对象的创建     
    <constant name="struts.objectFactory" value="spring" />  
    -->  
    <constant name="struts.objectFactory" value="com.opensymphony.xwork2.ObjectFactory" />
    <!-- 是否开启动态方法调用 -->  
    <constant name="struts.enable.DynamicMethodInvocation" value="false"/>  

报错信息:
HTTP Status 404 - There is no Action mapped for namespace [/test] and action name [init] associated with context path [/dome].

type Status report

message There is no Action mapped for namespace [/test] and action name [init] associated with context path [/dome].

description The requested resource (There is no Action mapped for namespace [/test] and action name [init] associated with context path [/dome].) is not available.
------解决方案--------------------
@namespace /tes  少了