struts2 命名空间错误的问题
大家好,我在学习<struts2权威指南>,途中遇到一个问题:就是namespace不对!
情况:
1,很多人说,jsp页面放在根目录不好,放在WEB-INF更加安全,所以我先在web.xml中,设置应用默认跳转到index.jsp。
2,从index.jsp跳转到WEB-INF/jsp下面的登录界面:
<jsp:forward page="WEB-INF/jsp/login.jsp"/>
<s:form id="loginForm" action ="loginAction">
<s:textfield name ="username" label="用户名"/>
<s:password name ="password" label ="密码"/>
<s:textfield name ="vercode" label ="验证码"/>
<s:submit value ="登陆"/>
<input type ="button" onclick ="jumpRegist();" value ="注册"/>
</s:form>
<package name="dg" extends="struts-default" >
<action name ="loginAction" class ="action.LoginAction" >
<result name ="input">WEB-INF/jsp/login.jsp</result>
<result name ="failure">WEB-INF/jsp/error.jsp</result>
</action>
</package>
<struts>
<!-- 开发模式,每次更改配置或者代码后,不用重启服务器 -->
<constant name="struts.devMode" value="true" />
<!-- 允许struts动态请求,只是调用struts里面的某个方法 -->
<constant name = "struts.enable.DynamicMethodInvocation" value = "true"/>
<!-- 空间名为/WEB-INF/page -->
<package name="deng" extends="struts-default" >
<!-- 配置全局result -->
<global-results>
<result name ="success">WEB-INF/jsp/sucess.jsp</result>
<result name ="exception">WEB-INF/jsp/error.jsp</result>
</global-results>
<!-- 配置全局的异常印射 -->
<global-exception-mappings>
<exception-mapping result="exception" exception="java.lang.Exception"/>
</global-exception-mappings>
<!-- 配置loginAction,registAction,使用通配符配置 -->
<action name ="loginAction" class ="action.LoginAction" >
<result name ="input">WEB-INF/jsp/login.jsp</result>
<result name ="failure">WEB-INF/jsp/error.jsp</result>
</action>
<action name ="registAction" class ="action.RegistAction">
<result name ="input">WEB-INF/jsp/login.jsp</result>
<result name ="failure">WEB-INF/jsp/error.jsp</result>
</action>
<!-- 这个是跳转页面用的,比如我跳转regist.jsp,那么只要请求是regits就可以了。 -->
<action name="*.jsp">
<result>WEB-INF/jsp/{1}.jsp</result>
</action>
</package>
<package name="web_inf_page" extends="struts-default" namespace="/WEB-INF/page" />
</struts>
<struts>
<!-- 开发模式,每次更改配置或者代码后,不用重启服务器 -->
<constant name="struts.devMode" value="true" />
<!-- 允许struts动态请求,只是调用struts里面的某个方法 -->
<constant name = "struts.enable.DynamicMethodInvocation" value = "true"/>
<!-- 空间名为/WEB-INF/page -->
<package name="deng" extends="struts-default" >
<!-- 配置全局result -->
<global-results>
<result name ="success">WEB-INF/jsp/sucess.jsp</result>
<result name ="exception">WEB-INF/jsp/error.jsp</result>
</global-results>
<!-- 配置全局的异常印射 -->
<global-exception-mappings>
<exception-mapping result="exception" exception="java.lang.Exception"/>
</global-exception-mappings>
<!-- 配置loginAction,registAction,使用通配符配置 -->
<action name ="loginAction" class ="action.LoginAction" >
<result name ="input">WEB-INF/jsp/login.jsp</result>
<result name ="failure">WEB-INF/jsp/error.jsp</result>
</action>
<action name ="registAction" class ="action.RegistAction">
<result name ="input">WEB-INF/jsp/login.jsp</result>
<result name ="failure">WEB-INF/jsp/error.jsp</result>
</action>
<!-- 这个是跳转页面用的,比如我跳转regist.jsp,那么只要请求是regits就可以了。 -->
<action name="*.jsp">
<result>WEB-INF/jsp/{1}.jsp</result>
</action>
</package>
<package name="web_inf_page" extends="deng" namespace="/WEB-INF/page" />
</struts>