Result结果视图的常用类型
来源:互联网 发布:淘宝加购什么意思 编辑:程序博客网 时间:2024/06/13 18:05
1.redirect:该结果类型用于将请求结果重定向到指定的视图资源。使用该结果视图的效果是:系统将调用HttpServletResponse.sendRedirect(String path)重定向到指定的视图资源,之前的所有请求参数、请求属性、Action实例以及该实例中封装的属性将全部丢失。
<action ...> <result type="redirect">/redirect.jsp</result></action>
2.redirectAction:该结果类型用于将请求结果重定向到指定的Action,配置该结果类型还需要配置两个参数:
1>actionName : 指定需要重定向的Action的name
2>namespace:指定需要重定向的Action所在的包命名空间
<package namespace="/chengxi1" extends="struts-default"> <action name="login" class="LoginAction"> <result type="redirectAction"> <param name="actionName">redirect</param> <param name="namespace">/chengxi2</param> </result> </action></package><package namespace="/chengxi2" extends="struts-default"> <action name="redirect" class="RedirectAction"> <result>/welcom.jsp</result> </action></package>
该结果类型的重定向机制为:先由当前action的result重定向到另一个Action,然后所有的请求参数等等都丢失了,这是一次全新的请求,类似与一个空请求给当前重定向Action,然后调用该Action的execute方法,最后根据该方法的返回值来选择并返回对应的视图资源
3>dispatcher:该结果类型用于转发到另一个页面,其使用方式和redirect类似,区别在于重定向和转发。
4>stream:该结果类型用于向浏览器返回一个InputStream,通常用于Struts2实现文件下载的情况,详见文章:http://blog.csdn.net/qq_27905183/article/details/52681744
5>plainText:该结果类型用于输出指定资源文件的源代码。使用该结果类型需要配置两个属性:
1>location:指定实际的视图资源
2>charSet:指定输出页面时所使用的字符集.该属性一般用于输出的资源文件包含中文字符的情况。
<action ...> <resule type="plainText"> <param name="location">welcome.jsp</param> <param name="charSet">GBK</param> </result></action>
1 0
- Result结果视图的常用类型
- Result中常用结果类型
- struts2的result结果类型
- struts2的result结果类型
- Struts2的result结果类型
- struts2的result结果类型
- result常用结果类型(dispatcher,redirect,redirectAction)及全局result
- Struts2结果视图result
- Struts2结果视图result
- Struts2框架提供的result结果类型
- 自定义结果类型(result的type属性)
- result的type属性中有哪几种结果类型?
- result配置的各种视图转发类型
- Struts2 拦截器 默认Action 一些常量的设置 Result常用的结果类型
- Struts2:Result结果类型
- result结果类型
- struts2中常用Result类型的用法
- struts2中常用Result类型的用法
- [转]触发器-锁存器-亚稳态
- archlinux内核开发
- Android知识总结
- 总结
- C ++友元的浅析(一)
- Result结果视图的常用类型
- 近20个绚丽实用的jQuery/CSS3侧边栏菜单
- oracle11g的BIN目录exp.exe
- LevelDB使用指南
- 使用org.apache.commons.httpclient.util.DateUtil工具类解析时间减少一天
- 微信小程序之swiper轮播图
- 来点不一样的:解耦 HTML、CSS 和 JS之间的那些事
- 数据库事物的 ACID 属性和 5 种状态
- EventBus学习笔记