Struts2中Action result各种转发类型
来源:互联网 发布:生物圈二号 知乎 编辑:程序博客网 时间:2024/05/09 09:33
原址:点击打开链接
内部请求转发dispatcher(默认值)、 redirect、redirectAction、plainText
1.redirect是重定向到某个路径、视图
<action name="redirect">
<result type="redirect">/employeeAdd.jsp?username=${username}</result>
</action>
URLEncoder.encode("传智播客","UTF-8");
取值解码在前台:
<% = URLDecoder.decode(new String(request.getParameter("username").getBytes("ISO8859-1"),"UTF-8"),"UTF-8") %>
2.redirectAction是重定向到某个Action
<action name="redirectAction">
<resutl type="redirectAction">Action的名称</resutl>
</action>
重定向到另一个包下的Action如何?
<action name="redirectAction">
<resutl type="redirectAction">
<param name="actionName">Action名称</param>给源代码的这两个属性注入值
<param name="namespace">/control/department</param>
</resutl>
</action>
3.plainText适用于查看某个JSP源代码即显示源代码的时候使用
<action name="plainText">
<resutl type="plainText">/index.jsp</result>
</action>
结果会将整个视图的源代码输出在浏览器上给用户看UTF-8的模式呈现不会说中文乱码
<action name="plainText">
<resutl type="plainText">
<param name="location">/index.jsp</param>
<param name="charSet">UTF-8</param>
</result>
</action>
大多数Action公用的视图配置
<global-results>
<result name="message">/WEB-INF/page/message.jsp</result>
</global-results>
这段代码放在某个<package></package>代码段中的Action是公用视图外如果想定义全局的话可以
<package name="base" extends="struts-default">
</package>
其它包继承 extentds="base"就OK 各个包中的Action使用公共视图就这样定义全局视图
为Action的属性注入值
要实现依赖注入必须提供Set方法
<struts>
<package name="itcast" namespace="/control/employee" extends="struts-default">
<action name="list" class="cn.itcast.action.HelloWorldAction" method="execute">
<param name="savepath">/images</param>给Action中的savepath属性注入的值
<result name="success">/WEB-INF/page/message.jsp</result>
</action>
</package>
</struts>
- Struts2中Action result各种转发类型
- Struts2中Action result各种转发类型
- struts2教程:5、Action中result的各种转发类型
- Struts2 中,action中的result的各种转发类型
- 【Struts2】④Action中result的各种转发类型
- Struts2:Action中result的各种转发类型
- Action中result的各种转发类型
- <Action>中<result>的各种转发类型
- Action中result的各种转发类型
- Action中result的各种转发类型
- Action中result的各种转发类型
- Action中result的各种转发类型
- 传智Struts2笔记(四)Action中result的各种转发类型
- 传智Struts2笔记(四)Action中result的各种转发类型
- struts2中Action配置中的各项默认值和result的各种转发类型
- struts2的框架解析第5篇action中result的各种转发类型
- Struts2 result各种转发类型
- Struts2中Action各种转发类型
- Button的使用(一):直接添加到Activity
- 请听一个故事------>讲述一段失败的创业经历 ,希望你能从中受到启发
- 第4周作业-数学学习工具
- Hive使用
- 日期时间脚本库方法列表
- Struts2中Action result各种转发类型
- ListView项不能完全填充的问题
- android R.java居然报错,Underscores can only be used with source level 1.7 or greater
- 6
- win7 32bit + opencv2.4.4 + qt 5.2.1搭配环境常见问题总结
- Button的使用(二):从资源文件中
- Spring - constructor-arg和property的使用示例
- 23种设计模式之python实现
- 面试第一天总结