首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

传智Struts2札记(四)Action中result的各种转发类型

2012-11-06 
传智Struts2笔记(四)Action中result的各种转发类型Action中result的各种转发类型action namehelloworld

传智Struts2笔记(四)Action中result的各种转发类型
Action中result的各种转发类型


<action name="helloworld" name="code"><result type="redirect">/view.jsp?id=${id}</result>


下面是redirectAction 结果类型的例子,如果重定向的action中同一个包下:
<result type="redirectAction">helloworld</result>

如果重定向的action在别的命名空间下:
<result type="redirectAction"><param name="actionName">helloworld</param><param name="namespace">/test</param></result>

plaintext:显示原始文件内容,例如:当我们需要原样显示jsp文件源代码 的时候,我们可以使用此类型。
<result name="source" type="plainText "><param name="location">/xxx.jsp</param><param name="charSet">UTF-8</param><!-- 指定读取文件的编码 --></result>



多个Action共享一个视图--全局result配置

当多个action中都使用到了相同视图,这时我们应该把result定义为全局视图。struts1中提供了全局forward,struts2中也提供了相似功能:
<package ....><global-results><result name="message">/message.jsp</result></global-results></package>

热点排行