struts2中result的各种type的作用

来源:互联网 发布:优化网站实例 编辑:程序博客网 时间:2024/05/17 06:36

一、jsp直接跳转到jsp

<action name="topUI">//不写class就直接跳到jsp
<result>/WEB-INF/pages/front/top.jsp</result>
</action>

<result type="redirect">/view.jsp?id=${action中的同名属性}</result>//用这种方式可以传递action中的参数到页面

二、action跳到action

1.需要保存前一个action的属性信息时使用:
<result type= "chain">action2</result>
2.不保存前一个action的属性信息时使用:
<result type= "redirect-action">action2</result>//struts2.1.6以后使用type=redirectAction方式

<result name="success" type="redirectAction">actionName</result>//同一个包下的action

<result name="success" type="redirectAction">//不同包下的action
<param name="actionName">indexUI</param>
<param name="namespace">/main</param>//跳到别的命名空间中的action
</result>

三、type="plainText"输出源代码到页面

<result name="showSource" type="plainText">
<param name="location">/xxx.jsp</param>
<param name="charSet">UTF-8</param>//指定读取文件的编码
</result>




转载自:http://hi.baidu.com/liuzy84/blog/item/96a7bfecd6e2582b63d09f12.html

原创粉丝点击