1、struts.xml 配置
<action name ="file_*" class="FileUploadAction" method='{1}'>
<interceptor-ref name ="fileUploadStack" />
<result name="constructFilePage">/pages/serviceManage/fileUpLoad.jsp</result>
<!--result name="success" type="chain">file_constructFilePage
</result-->
<result name="success" type="redirect">file_constructFilePage.action
</result> (这种写法要加上.action)
</action>
当type为chain 时,说明是action链,运行完第一个action java文件接着会运行第二个action JAVA 文件,相当于forward(客户端的url不会改变).当type为redirect-action时,说明会跳转到第二个action的url ,相当于redirect (客户端的url会改变)
2、后台action自执行跳转
例如:
public void test(){
...
...
ServletActionContext.getResponse().sendRedirect("pages/serviceManage/serviceIndex.jsp?path="+npath);
}
本文介绍Struts框架中struts.xml配置方法,包括如何设置action映射、拦截器及结果页面。同时讲解了不同result类型(chain与redirect-action)的区别,并提供了后台action自执行跳转的具体实现。
4843

被折叠的 条评论
为什么被折叠?



