Struts2的<result>结果
来源:互联网 发布:菜鸟网络 高科技园区 编辑:程序博客网 时间:2024/04/28 17:25
1.结果视图:局部和全局逻辑视图
1.1 局部逻辑视图:只服务于当前的动作
1.2 全局逻辑视图:服务于所有的动作
//全局逻辑视图:所有动作没有name = success 的局部视图,到全局视图找
更好的利用package的继承性组织全局视图:
2.自定义结果类型:CAPTCHA图像
2.1所有的结果类型都是直接或间接的实现了Result接口
2.2自定义结果类型的开发步骤
1) 直接或间接实现Result接口
//输出随机验证码图片public class CaptchaResult extends StrutsResultSupport {private int width = 120;private int height = 20;public void setWidth(int width) {this.width = width;}public void setHeight(int height) {this.height = height;}protected void doExecute(String finalLocation, ActionInvocation invocation)throws Exception {ValidateCode code = new ValidateCode(width, height, 4, 9);HttpServletResponse response = ServletActionContext.getResponse();code.write(response.getOutputStream());}}
2) 在struts.xml中声明结果类型
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE struts PUBLIC"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN""http://struts.apache.org/dtds/struts-2.3.dtd"><struts><constant name="struts.devMode" value="true"></constant><package name="default" extends="struts-default" abstract="true"><result-types><result-type name="captcha" class="com.itheima.results.CaptchaResult"></result-type></result-types></package></struts>
3) 在动作中使用自定义的结果类型
<package name="p1" extends="default"><action name="captcha"><result name="success" type="captcha"><param name="width">120</param><param name="height">25</param></result></action><action name="action1"></action></package>
0 0
- Struts2的<result>结果
- struts2的result结果类型
- struts2的result结果类型
- Struts2的result结果类型
- struts2的result结果类型
- Result——Struts2的处理结果
- Struts2框架提供的result结果类型
- Struts2:Result结果类型
- Struts2结果视图result
- Struts2结果视图result
- Struts2结果类型(Result Types)
- struts2 result结果为action
- Struts2 result type(结果类型)
- struts2 result全局结果集
- struts2 result type(结果类型)
- Struts2 result type(结果类型)
- Struts2 result type(结果类型)
- Struts2 result type(结果类型)
- libconfig++示例详解
- HDU - 3177 Crixalis's Equipment
- JSP主要用法及共享总结
- 一次Android面试题
- 1034. Head of a Gang
- Struts2的<result>结果
- 程序员必须知道的10大基础实用算法及其讲解
- 常见进程调度算法
- 过滤器
- 1035. Password
- 这半年给自己的一个定位
- 获取一个文本上每个字符出现的次数,将结果写在times.txt上
- 1036. Boys vs Girls
- Eclipse编译使用SO步骤