详解Struts2支持的结果类型(三)
来源:互联网 发布:mac ae 2014破解 编辑:程序博客网 时间:2024/04/29 14:04
学习网址:http://www.yiibai.com/struts_2/struts_result_types.html
(一)打开struts2-core-2.3.16.1.jar包下的struts-default.xml文件
<result-types><!--处理Action链式结果类型--> <result-type name="chain" class="com.opensymphony.xwork2.ActionChainResult"/> <!-- 指定要转发到的JSP页面--> <result-type name="dispatcher" class="org.apache.struts2.dispatcher.ServletDispatcherResult" default="true"/><!-- 指定使用freemarker模板作为要显示的页面--> <result-type name="freemarker" class="org.apache.struts2.views.freemarker.FreemarkerResult"/> <!-- 用于控制特殊的HTTP行为 --> <result-type name="httpheader" class="org.apache.struts2.dispatcher.HttpHeaderResult"/> <!--用于重定向到其他JSP页面,但其无法在URL添加请求参数,因为数据会丢失--> <result-type name="redirect" class="org.apache.struts2.dispatcher.ServletRedirectResult"/> <!-- 用于重定向到指定Action--> <result-type name="redirectAction" class="org.apache.struts2.dispatcher.ServletActionRedirectResult"/> <!-- 向浏览器返回一个InputStream --> <result-type name="stream" class="org.apache.struts2.dispatcher.StreamResult"/> <!-- velocity用于指定velocity作为视图页面 --> <result-type name="velocity" class="org.apache.struts2.dispatcher.VelocityResult"/> <!-- 用于与XML/XSLT整合 --> <result-type name="xslt" class="org.apache.struts2.views.xslt.XSLTResult"/> <!-- 用于显示指定页面的原代码--> <result-type name="plainText" class="org.apache.struts2.dispatcher.PlainTextResult" /> <!-- --> <result-type name="postback" class="org.apache.struts2.dispatcher.PostbackResult" /> </result-types>
(二)常使用的结果类型
1.type=”dispatcher”
<action name="hello" class="com.wang.HelloWorldAction" method="execute"> <!--默认就是type="dispatcher"可以不写--> <result name="success" type="dispatcher">/HelloWorld.jsp</result> </action>
说明:
1.默认类型为dispatcher,转发地址栏URL不变,请求参数不丢失
2.表单数据提交及连接都使用了dispatcher跳转页面
实例结果演示
2.type=”redirect”
<action name="hello" class="com.wang.HelloWorldAction" method="execute"> <result name="success" type="redirect" >/HelloWorld.jsp</result></action>
说明:
1.重定向的效果等同于重新产生一个HTTP请求,请求参数、请求属性、Action实例、Action封装的数据全部丢失。
实例结果演示:
3.type=”redirectAction”
<action name="hello" class="com.wang.HelloWorldAction" method="execute"> <!--重定向到redirectActionDemo的URL--> <result name="success" type="redirectAction" >HaHa</result> </action> <!----> <action name="HaHa" class="com.wang.HelloWorldAction" method="execute"> <result name="success">/HelloWorld.jsp</result> </action>
说明:
1.第一个Action执行完某一个方法后,不跳转到JSP页面,而是重定向到下一个Action。当下一个Action执行完某一个方法后可以跳转到JSP视图页面,也可以不跳转到JSP视图页面。
2.使用redirectAction重定向,请求参数、请求属性、Action实例、Action封装的数据全部丢失。
实例结果演示:
阅读全文
0 0
- 详解Struts2支持的结果类型(三)
- struts2 支持的结果类型
- Struts2支持的结果类型
- Struts2支持的结果类型
- struts2支持的处理结果类型
- struts2的result结果类型
- struts2的result结果类型
- Struts2的result结果类型
- struts2返回结果的类型
- struts2的result结果类型
- struts2的14种内建结果类型
- Struts2中Action的返回结果类型
- Struts2框架提供的结果类型
- Struts2框架提供的结果类型
- 【转】Struts2框架提供的结果类型
- Struts2 中Action的结果类型
- Struts2的常用结果类型分析
- Struts2框架提供的结果类型
- 深度学习-ubuntu之路a
- KD-Tree 算法的 C++ 实现
- 【MyBatis框架】MyBatis的逆向工程生成代码,如何生成逆向工程
- 深入JavaScript
- 292. Nim Game
- 详解Struts2支持的结果类型(三)
- Junit测试
- 用DOM解析XML时换行和空格
- Apache Hadoop 3.0.0 GA 版本终于发布
- linux mint,ubuntu快速安装 docker
- 网站优化 大并发 大流量 大存储 负载均衡 集群
- Java 理解 子类成员变量与父类成员变量同名 方法的重写
- hbase常见错误----单机版hbase启动失败zookeeper.RecoverableZooKeeper: ZooKeeper exists failed after...
- python安装beautifulSoup