博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【web开发学习笔记】Structs2 Result学习笔记(一)简介
阅读量:7071 次
发布时间:2019-06-28

本文共 2902 字,大约阅读时间需要 9 分钟。

Structs2 Result学习笔记(一)简介

问题一

/r1.jsp
/r2.jsp
r1
r2
    dispatcher -   forward运用server跳转  server跳转    显示action

    redirect   -   重定向 跳转到jsp

    chain  server跳转

    redirectAction

问题二

    chain跳转 -> 从一个action,跳转至另外一个包里面的action的方法:
login
dashboard
/secure
dashboard.jsp
    通过样例能够看出,是通过为chain配置actionName參数和namespace參数。
    详细实例參见struts-2.1.6/docs/docs/chain-result.html里面的文档说明。

问题三。全局Result

//前端htm			Result类型	

type=1">返回success</a></li> <li><a href="user/user?

type=2">返回error</a></li> <li><a href="user/user?

type=3">返回global result</a></li> <li><a href="admin/admin">admin,继承user包</a></li> </ol> </body>

//struct.xml
/main.jsp
/index.jsp
/user_success.jsp
/user_error.jsp
/admin.jsp
//类包//AdminActionpackage com.struts2.user.action;import com.opensymphony.xwork2.ActionSupport;public class AdminAction extends ActionSupport {	@Override	public String execute() throws Exception {		return "mainpage";	}}//UserActionpackage com.struts2.user.action;import com.opensymphony.xwork2.ActionSupport;public class UserAction extends ActionSupport {	private int type;	public int getType() {		return type;	}	public void setType(int type) {		this.type = type;	}	@Override	public String execute() throws Exception {		if(type == 1) return "success";		else if (type == 2) return "error";		else return "mainpage";	}}

分析1

/main.jsp
/index.jsp
/user_success.jsp
/user_error.jsp
这段配置文件里,result 为success时。调用user_success.jsp,result为error时,调用
/user_error.jsp。其余全部的情况都使用result为mainpage的配置。能够共用这个结果集。

分析二

/admin.jsp
extends的作用是从另外一个包里面继承配置信息,工作中使用对项目进行分模块处理,每一个模块都有公共的配置信息,这样能够将公共配置信息定义为<global-results>。然后被各个模块继承,简化处理。和c++/java中的继承关系好像啊!

问题四:struct-default解析

源文件在ReferencedLibraries/WebRoot/WEB-INF/lib/struts2-core-2.1.6.jar/struct-default.xml
默认定义了拦截器
    结论:配置非常复杂,使用不需改。

转载地址:http://gahll.baihongyu.com/

你可能感兴趣的文章
Android全局对话框
查看>>
awstats 分析nginx 日志
查看>>
给zabbix添加短信、微信、邮件报警
查看>>
MPChart 使用参考博客
查看>>
java: command not found
查看>>
单机上使用git#180804
查看>>
nginx+tomcat负载均衡
查看>>
php-编译安装
查看>>
感谢2011
查看>>
power shell 远程连接
查看>>
你的灯还亮着吗
查看>>
android手机在slackware linux上的调试
查看>>
mysql性能优化配置
查看>>
JavaScript继承方式详解
查看>>
解决win7旗舰版无法打开微软论坛
查看>>
烂泥:高负载均衡学习haproxy之安装与配置
查看>>
Web.config配置文件详解(新手必看)<转>
查看>>
【转】shell编程:数学运算
查看>>
ASP.NET
查看>>
使用mosh取代ssh提高n2n网络连接稳定性
查看>>