1stuts2_redirctAction在struts.xml中的配置问题
2012-03-02 23:51
363 查看
package name="testFrame" extends="struts-default" >
<action name="login" class="com.ben.test.action.Login" >
<result name="success">/common/true.jsp</result>
<result name="error">/common/false.jsp</result>
<result name="input" type="dispatcher" >/test/login/login.jsp</result>
<result name="container" type="redirectAction">
<!--在下面这一行总是出现 Undefined actionnamespace parameter-->
<param name="actionName">books</param>
</result>
<!-- 如果不写type属性,默认就是dispatcher;相当于forward,有相同的request context -->
</action>
<action name="books" class="com.ben.test.action.BookList">
<result name="success">/common/true.jsp</result>
<result name="error">/common/false.jsp</result>
<result name="listJsp" >/test/list.jsp</result>
<!-- 如果不写type属性,默认就是dispatcher;相当于forward,有相同的request context -->
</action>
</package>
因为涉及到action之间的跳转,为了不引起混乱和尽快找到相应的action必须为该package指定namespace,所以需要改为如下的形式方能正常工作:
<package name="testFrame" extends="struts-default" namespace="/testFrameFlow">
<action name="login" class="com.ben.test.action.Login" >
<result name="success">/common/true.jsp</result>
<result name="error">/common/false.jsp</result>
<result name="input" type="dispatcher" >/test/login/login.jsp</result>
<result name="container" type="redirectAction">
<param name="actionName">books</param>
<param name="namespace">/testFrameFlow</param>
</result>
<!-- 如果不写type属性,默认就是dispatcher;相当于forward,有相同的request context -->
</action>
<action name="books" class="com.ben.test.action.BookList">
<result name="success">/common/true.jsp</result>
<result name="error">/common/false.jsp</result>
<result name="listJsp" >/test/list.jsp</result>
<!-- 如果不写type属性,默认就是dispatcher;相当于forward,有相同的request context -->
</action>
</package>
这时候前台提交代码也必须要指定相应的namespace,具体如下:
<s:form action="login" method="post" namespace="/testFrameFlow">
要注意黄色背景部分是action="login" 而不是 action="login.action"
虽然我web.xml的过滤器是这样子写的:
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
由此可以看出,
1,当在提交表单的时候指定namespace时,后面的.action就不需要添加了,原因是当这个表单提交到相应的namespace="/testFrame/Flow"时,就已经被struts拦截器所捕获,所以就不需要添加.action了。
2,如果要是我要提交的表单没有指定属于struts拦截范围的namespace,这个时候就需要用action="login.action"了,否则,struts是拦截不到这个请求的。
package name="testFrame" extends="struts-default" >
<action name="login" class="com.ben.test.action.Login" >
<result name="success">/common/true.jsp</result>
<result name="error">/common/false.jsp</result>
<result name="input" type="dispatcher" >/test/login/login.jsp</result>
<result name="container" type="redirectAction">
<!--在下面这一行总是出现 Undefined actionnamespace parameter-->
<param name="actionName">books</param>
</result>
<!-- 如果不写type属性,默认就是dispatcher;相当于forward,有相同的request context -->
</action>
<action name="books" class="com.ben.test.action.BookList">
<result name="success">/common/true.jsp</result>
<result name="error">/common/false.jsp</result>
<result name="listJsp" >/t
9849
est/list.jsp</result>
<!-- 如果不写type属性,默认就是dispatcher;相当于forward,有相同的request context -->
</action>
</package>
<
这时候前台提交代码也必须要指定相应的namespace,具体如下:
<s:form action="login" method="post" namespace="/testFrameFlow">
要注意黄色背景部分是action="login" 而不是 action="login.action"
虽然我web.xml的过滤器是这样子写的:
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
由此可以看出,
1,当在提交表单的时候指定namespace时,后面的.action就不需要添加了,原因是当这个表单提交到相应的namespace="/testFrame/Flow"时,就已经被struts拦截器所捕获,所以就不需要添加.action了。
2,如果要是我要提交的表单没有指定属于struts拦截范围的namespace,这个时候就需要用action="login.action"了,否则,struts是拦截不到这个请求的。
<action name="login" class="com.ben.test.action.Login" >
<result name="success">/common/true.jsp</result>
<result name="error">/common/false.jsp</result>
<result name="input" type="dispatcher" >/test/login/login.jsp</result>
<result name="container" type="redirectAction">
<!--在下面这一行总是出现 Undefined actionnamespace parameter-->
<param name="actionName">books</param>
</result>
<!-- 如果不写type属性,默认就是dispatcher;相当于forward,有相同的request context -->
</action>
<action name="books" class="com.ben.test.action.BookList">
<result name="success">/common/true.jsp</result>
<result name="error">/common/false.jsp</result>
<result name="listJsp" >/test/list.jsp</result>
<!-- 如果不写type属性,默认就是dispatcher;相当于forward,有相同的request context -->
</action>
</package>
因为涉及到action之间的跳转,为了不引起混乱和尽快找到相应的action必须为该package指定namespace,所以需要改为如下的形式方能正常工作:
<package name="testFrame" extends="struts-default" namespace="/testFrameFlow">
<action name="login" class="com.ben.test.action.Login" >
<result name="success">/common/true.jsp</result>
<result name="error">/common/false.jsp</result>
<result name="input" type="dispatcher" >/test/login/login.jsp</result>
<result name="container" type="redirectAction">
<param name="actionName">books</param>
<param name="namespace">/testFrameFlow</param>
</result>
<!-- 如果不写type属性,默认就是dispatcher;相当于forward,有相同的request context -->
</action>
<action name="books" class="com.ben.test.action.BookList">
<result name="success">/common/true.jsp</result>
<result name="error">/common/false.jsp</result>
<result name="listJsp" >/test/list.jsp</result>
<!-- 如果不写type属性,默认就是dispatcher;相当于forward,有相同的request context -->
</action>
</package>
这时候前台提交代码也必须要指定相应的namespace,具体如下:
<s:form action="login" method="post" namespace="/testFrameFlow">
要注意黄色背景部分是action="login" 而不是 action="login.action"
虽然我web.xml的过滤器是这样子写的:
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
由此可以看出,
1,当在提交表单的时候指定namespace时,后面的.action就不需要添加了,原因是当这个表单提交到相应的namespace="/testFrame/Flow"时,就已经被struts拦截器所捕获,所以就不需要添加.action了。
2,如果要是我要提交的表单没有指定属于struts拦截范围的namespace,这个时候就需要用action="login.action"了,否则,struts是拦截不到这个请求的。
package name="testFrame" extends="struts-default" >
<action name="login" class="com.ben.test.action.Login" >
<result name="success">/common/true.jsp</result>
<result name="error">/common/false.jsp</result>
<result name="input" type="dispatcher" >/test/login/login.jsp</result>
<result name="container" type="redirectAction">
<!--在下面这一行总是出现 Undefined actionnamespace parameter-->
<param name="actionName">books</param>
</result>
<!-- 如果不写type属性,默认就是dispatcher;相当于forward,有相同的request context -->
</action>
<action name="books" class="com.ben.test.action.BookList">
<result name="success">/common/true.jsp</result>
<result name="error">/common/false.jsp</result>
<result name="listJsp" >/t
9849
est/list.jsp</result>
<!-- 如果不写type属性,默认就是dispatcher;相当于forward,有相同的request context -->
</action>
</package>
<
这时候前台提交代码也必须要指定相应的namespace,具体如下:
<s:form action="login" method="post" namespace="/testFrameFlow">
要注意黄色背景部分是action="login" 而不是 action="login.action"
虽然我web.xml的过滤器是这样子写的:
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
由此可以看出,
1,当在提交表单的时候指定namespace时,后面的.action就不需要添加了,原因是当这个表单提交到相应的namespace="/testFrame/Flow"时,就已经被struts拦截器所捕获,所以就不需要添加.action了。
2,如果要是我要提交的表单没有指定属于struts拦截范围的namespace,这个时候就需要用action="login.action"了,否则,struts是拦截不到这个请求的。
相关文章推荐
- 【开发过程问题汇总系列】【B/S struts2】加好jar包且配置好struts.xml后action还是无法请求的问题
- 【Struts2文件下载】struts.xml文件中配置action,访问路径问题
- Struts 配置拦截器导致 验证的某某Action-vationdation.xml文件不好使的问题
- Struts2中struts.xml的Action、namespace配置详解
- 问题:struts.xml中配置package出错
- struts.xml属性配置,action属性,通配符,action接受参数(二)
- Struts-config.xml配置文件《action-mappings》元素的详解
- Struts2学习笔记之struts.xml配置常量和Action处理流程
- struts.xml配置文件(package,namespace,action)
- struts1和spring进行整合的时候struts-config.xml文件的配置顺序问题
- StrutsTestCase配置的常见问题及其多级Action的处理方式
- struts.xml配置文件中的action的各项默认值
- struts.xml中配置一个action调用另一个action
- Struts-config.xml配置文件《action-mappings》元素的详解
- Structs 在Struts.xml中配置action时,action的name属性最好首字母大写
- 关于用struts所配置的Action默认页面的跳转问题
- struts.xml配置文件(package,namespace,action)
- struts-config.xml配置文件出错的问题及其解决
- struts.xml配置文件(package,namespace,action)
- Struts2 在struts.xml配置Action