- 浏览: 311800 次
- 性别:
- 来自: 济南
文章分类
- 全部博客 (221)
- J2SE心得 (4)
- 经典帖子 (8)
- 亲身经历 (9)
- SSH框架 (12)
- 数据库 (10)
- java基础知识 (41)
- java解惑 (17)
- 软件测试 (0)
- JSP (6)
- JavaScript (8)
- jQuery学习 (12)
- 硬件知识 (1)
- 工具类 (14)
- 面试专题 (4)
- Struts2专题(学习) (14)
- Spring源码分析专题(学习) (15)
- JavaScript专题(学习) (8)
- ExtJs专题(学习) (6)
- Java Web快速入门——全十讲 (10)
- web前台 (1)
- J2ME手机方面 (1)
- 积累整理 (1)
- MyEclipse工具篇 (10)
- oracle (1)
- Android基础 (1)
最新评论
-
youjianbo_han_87:
上传成功后,无法跳转到success页面,会报2038和404 ...
Struts2使用FlashFileUpload.swf实现批量文件上传 -
showzh:
...
MyEclipse 怎么安装SVN插件 -
wpf523:
赞一个啊,楼主加油
一些比较复杂的运算符(二) -
独步天下:
request.getSession().getAttribute() 和request.getSession().setAttribute() -
HelloJava1234:
thank you
怎么改变MyEclipse默认的jsp打开方式
本篇主要通过实例来讲述Struts2中各种各样的参数传递。这个参数传递的过程主要指数据从View层传递到Control层时Struts2的工作方式。根据前两篇文章的知识,我们知道,Struts2完成参数传递处理工作的基础是OGNL和ValueStack。而在这个过程中,我也把Struts2所要做的工作大致归纳为两个方面:
1. 对OGNL操作进行封装,完成OGNL表达式所表示的值到Java对象的值传递机制
2. 在参数传递的过程中,做恰当的类型转化,保证页面上的字符串能够转化成各式各样的Java对象
接下来,通过四个不同的角度,来具体讲述Struts2在这两个方面的工作。
最简单的参数传递
使用OGNL的最基本的功能,就能完成普通的Java对象的赋值工作。Struts2在内部已经完成了OGNL的基本封装。这些封装包括对OGNL表达式到Java对象的赋值机制,以及对基本的Java类型的类型转化支持。这些基本类型包括String、Number(以及其基本类型int、float、double等)、Boolean(boolean)、数组、Class、Date等类型。
在这里我想额外强调的是XWork对JDK5.0中的Enum类型和Date类型的支持。
Enum类型
枚举类型是JDK5.0引入的新特性。枚举类型也能解决很多实际问题,是J2EE编程中的最佳实践之一。XWork中,有一个专门的EnumTypeConverter负责对Enum类型的数据进行转化。
- public class EnumTypeConverter extends DefaultTypeConverter {
- /**
- * Converts the given object to a given type. How this is to be done is implemented in toClass. The OGNL context, o
- * and toClass are given. This method should be able to handle conversion in general without any context or object
- * specified.
- *
- * @param context - OGNL context under which the conversion is being done
- * @param o - the object to be converted
- * @param toClass - the class that contains the code to convert to enumeration
- * @return Converted value of type declared in toClass or TypeConverter.NoConversionPossible to indicate that the
- * conversion was not possible.
- */
- public Object convertValue(Map context, Object o, Class toClass) {
- if (o instanceof String[]) {
- return convertFromString(((String[]) o)[0], toClass);
- } else if (o instanceof String) {
- return convertFromString((String) o, toClass);
- }
- return super.convertValue(context, o, toClass);
- }
- /**
- * Converts one or more String values to the specified class.
- * @param value - the String values to be converted, such as those submitted from an HTML form
- * @param toClass - the class to convert to
- * @return the converted object
- */
- public java.lang.Enum convertFromString(String value, Class toClass) {
- return Enum.valueOf(toClass, value);
- }
- }
public class EnumTypeConverter extends DefaultTypeConverter { /** * Converts the given object to a given type. How this is to be done is implemented in toClass. The OGNL context, o * and toClass are given. This method should be able to handle conversion in general without any context or object * specified. * * @param context - OGNL context under which the conversion is being done * @param o - the object to be converted * @param toClass - the class that contains the code to convert to enumeration * @return Converted value of type declared in toClass or TypeConverter.NoConversionPossible to indicate that the * conversion was not possible. */ public Object convertValue(Map context, Object o, Class toClass) { if (o instanceof String[]) { return convertFromString(((String[]) o)[0], toClass); } else if (o instanceof String) { return convertFromString((String) o, toClass); } return super.convertValue(context, o, toClass); } /** * Converts one or more String values to the specified class. * @param value - the String values to be converted, such as those submitted from an HTML form * @param toClass - the class to convert to * @return the converted object */ public java.lang.Enum convertFromString(String value, Class toClass) { return Enum.valueOf(toClass, value); } }
有了这个类,我们就可以比较轻松的对枚举类型进行数据赋值了。
public enum Gender { MALE, FEMALE }
- <form method="post" action="/struts-example/enum-conversion.action">
- <input type="text" name="user.name" value="downpour" />
- <select name="user.gender">
- <option value="MALE">男</option>
- <option value="FEMALE">女</option>
- </select>
- <input type="submit" value="submit" />
- </form>
<form method="post" action="/struts-example/enum-conversion.action"> <input type="text" name="user.name" value="downpour" /> <select name="user.gender"> <option value="MALE">男</option> <option value="FEMALE">女</option> </select> <input type="submit" value="submit" /> </form>
- public class EnumConversionAction extends ActionSupport {
- private static final Log logger = LogFactory.getLog(Policy.class);
- private User user;
- /* (non-Javadoc)
- * @see com.opensymphony.xwork2.ActionSupport#execute()
- */
- @Override
- public String execute() throws Exception {
- logger.info("user's gender:" + user.getGender());
- return super.execute();
- }
- // setters and getters
- }
public class EnumConversionAction extends ActionSupport { private static final Log logger = LogFactory.getLog(Policy.class); private User user; /* (non-Javadoc) * @see com.opensymphony.xwork2.ActionSupport#execute() */ @Override public String execute() throws Exception { logger.info("user's gender:" + user.getGender()); return super.execute(); } // setters and getters }
通过上面的代码,就完成了对枚举类型的赋值。不过这里有一点需要特别指出:那就是XWork在XWork-2.1.X的版本之前,枚举类型不被默认支持。如果你需要获得枚举类型的自动赋值,还需要增加一个配置文件xwork-conversion.properties到classpath下:
java.lang.Enum=com.opensymphony.xwork2.util.EnumTypeConverter
对于使用新的版本的XWork的朋友,则不需要增加这个配置文件。
Date类型
XWork默认是支持Date类型的转化的。不过从源码上来看,貌似我们很难用上它默认的类型转化。
- private Object doConvertToDate(Map context, Object value, Class toType) {
- Date result = null;
- if (value instanceof String && value != null && ((String) value).length() > 0) {
- String sa = (String) value;
- Locale locale = getLocale(context);
- DateFormat df = null;
- if (java.sql.Time.class == toType) {
- df = DateFormat.getTimeInstance(DateFormat.MEDIUM, locale);
- } else if (java.sql.Timestamp.class == toType) {
- Date check = null;
- SimpleDateFormat dtfmt = (SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.SHORT,
- DateFormat.MEDIUM,
- locale);
- SimpleDateFormat fullfmt = new SimpleDateFormat(dtfmt.toPattern() + MILLISECOND_FORMAT,
- locale);
- SimpleDateFormat dfmt = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT,
- locale);
- SimpleDateFormat[] fmts = {fullfmt, dtfmt, dfmt};
- for (int i = 0; i < fmts.length; i++) {
- try {
- check = fmts[i].parse(sa);
- df = fmts[i];
- if (check != null) {
- break;
- }
- } catch (ParseException ignore) {
- }
- }
- } else if (java.util.Date.class == toType) {
- Date check = null;
- SimpleDateFormat d1 = (SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG, locale);
- SimpleDateFormat d2 = (SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale);
- SimpleDateFormat d3 = (SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale);
- SimpleDateFormat rfc3399 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
- SimpleDateFormat[] dfs = {d1, d2, d3, rfc3399}; //added RFC 3339 date format (XW-473)
- for (int i = 0; i < dfs.length; i++) {
- try {
- check = dfs[i].parse(sa);
- df = dfs[i];
- if (check != null) {
- break;
- }
- }
- catch (ParseException ignore) {
- }
- }
- }
- //final fallback for dates without time
- if (df == null) {
- df = DateFormat.getDateInstance(DateFormat.SHORT, locale);
- }
- try {
- df.setLenient(false); // let's use strict parsing (XW-341)
- result = df.parse(sa);
- if (!(Date.class == toType)) {
- try {
- Constructor constructor = toType.getConstructor(new Class[]{long.class});
- return constructor.newInstance(new Object[]{new Long(result.getTime())});
- } catch (Exception e) {
- throw new XWorkException("Couldn't create class " + toType + " using default (long) constructor", e);
- }
- }
- } catch (ParseException e) {
- throw new XWorkException("Could not parse date", e);
- }
- } else if (Date.class.isAssignableFrom(value.getClass())) {
- result = (Date) value;
- }
- return result;
- }
private Object doConvertToDate(Map context, Object value, Class toType) { Date result = null; if (value instanceof String && value != null && ((String) value).length() > 0) { String sa = (String) value; Locale locale = getLocale(context); DateFormat df = null; if (java.sql.Time.class == toType) { df = DateFormat.getTimeInstance(DateFormat.MEDIUM, locale); } else if (java.sql.Timestamp.class == toType) { Date check = null; SimpleDateFormat dtfmt = (SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale); SimpleDateFormat fullfmt = new SimpleDateFormat(dtfmt.toPattern() + MILLISECOND_FORMAT, locale); SimpleDateFormat dfmt = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT, locale); SimpleDateFormat[] fmts = {fullfmt, dtfmt, dfmt}; for (int i = 0; i < fmts.length; i++) { try { check = fmts[i].parse(sa); df = fmts[i]; if (check != null) { break; } } catch (ParseException ignore) { } } } else if (java.util.Date.class == toType) { Date check = null; SimpleDateFormat d1 = (SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG, locale); SimpleDateFormat d2 = (SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.MEDIUM, locale); SimpleDateFormat d3 = (SimpleDateFormat) DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale); SimpleDateFormat rfc3399 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss"); SimpleDateFormat[] dfs = {d1, d2, d3, rfc3399}; //added RFC 3339 date format (XW-473) for (int i = 0; i < dfs.length; i++) { try { check = dfs[i].parse(sa); df = dfs[i]; if (check != null) { break; } } catch (ParseException ignore) { } } } //final fallback for dates without time if (df == null) { df = DateFormat.getDateInstance(DateFormat.SHORT, locale); } try { df.setLenient(false); // let's use strict parsing (XW-341) result = df.parse(sa); if (!(Date.class == toType)) { try { Constructor constructor = toType.getConstructor(new Class[]{long.class}); return constructor.newInstance(new Object[]{new Long(result.getTime())}); } catch (Exception e) { throw new XWorkException("Couldn't create class " + toType + " using default (long) constructor", e); } } } catch (ParseException e) { throw new XWorkException("Could not parse date", e); } } else if (Date.class.isAssignableFrom(value.getClass())) { result = (Date) value; } return result; }
这段代码就是XWork处理将String转成Date类型的过程,从整个过程上来看,我们很难用上这段代码,因为我们在界面上的Date类型的表现形式往往是:'yyyy-MM-dd'或者相关的形式,很明显,上面的流程无法匹配这样的日期类型。
所以,针对Date,我们往往会自定义一个日期转化的类进行处理,这个在下面会有具体的介绍。
Array、List、Map等容器类型的参数传递
除了简单的基于JavaBean方式的参数传递支持,Struts2还支持对Array、List、Map等容器类型的数据结构做数据赋值。不过历史一路走来,XWork针对容器类型的数据赋值一直有变化,让我们慢慢解读这些变化,从而也来看看编程思路是如何改变的。
1. 2004年,XWork-1.0.X的年代
当时XWork所支持的针对容器的数据赋值还比较土。这方面moxie在论坛上有一篇文章专门来讲述:http://www.iteye.com/topic/8770。
总的来说,那个年代对于容器的数据赋值,需要依赖于XWork的辅助类。我们可以看到,如果你要对List进行赋值,需要新建一个XWorkList的实现类,并把所需要进行数据赋值的Java类传递到XWorkList的构造函数中。而对Map等对象的赋值,也同理可得。
这种数据赋值的方式的优缺点都非常明显。优点在于简单,你不需要额外定义任何其他的内容,而是直接使用XWork的辅助类来实现类型转化。缺点在于扩展性很弱,很明显,针对某一个具体的容器,就需要一个XWork的实现类,List有XWorkList对应,Map有XWorkMap对应。甚至在那个时候,还没有Set的支持,因为没有XWorkSet的实现。所以使用这种方式,在扩展性方面需要遭受严重的考验。
2. 2006年,XWork-2.0.X的年代
也许是XWork团队看到了扩展性上的问题,所以在XWork和Webwork同时升级以后,采用了新的方式来处理容器赋值。而此时,Javaeye上也涌现出了新的文章,Tin同学对新的方式做了详细的表述:http://www.iteye.com/topic/17939。
不过这个新的整合方式似乎并不被大家所看好。
这种新的整合方式,实际上只是解决了针对容器赋值,不需要依赖XWork的辅助类这样的一个问题,不过其付出的代价,却是多了一个配置文件,这也让人非常郁闷。好好的类型转化,平白无故多出了一个同package下的配置文件,这也无形中增加了编程的复杂度。
3. 现在,拥抱了泛型和Annotation的年代
实际上,在XWork发展到XWork-2.0.X之后,也开始注重了对泛型和Annotation的支持。所以,容器类型的转化,我们也可以尝试一下使用JDK的新特性来进行,当然这也是目前最为推荐的做法。
下面分别给出使用泛型和Annotation的代码示例:
- <form method="post" action="/struts-example/ognl-collection-conversion.action">
- <input type="text" name="users[0].name" value="aaa" />
- <input type="text" name="users[1].name" value="bbb" />
- <input type="text" name="users2[0].name" value="ccc" />
- <input type="text" name="users2[1].name" value="ddd" />
- <input type="text" name="userMap['user1'].name" value="eee" />
- <input type="text" name="userMap['user2'].name" value="fff" />
- <input type="text" name="userMap2['user3'].name" value="ggg" />
- <input type="text" name="userMap2['user4'].name" value="hhh" />
- <input type="submit" value="submit" />
- </form>
<form method="post" action="/struts-example/ognl-collection-conversion.action"> <input type="text" name="users[0].name" value="aaa" /> <input type="text" name="users[1].name" value="bbb" /> <input type="text" name="users2[0].name" value="ccc" /> <input type="text" name="users2[1].name" value="ddd" /> <input type="text" name="userMap['user1'].name" value="eee" /> <input type="text" name="userMap['user2'].name" value="fff" /> <input type="text" name="userMap2['user3'].name" value="ggg" /> <input type="text" name="userMap2['user4'].name" value="hhh" /> <input type="submit" value="submit" /> </form>
- public class OgnlConversionAction extends ActionSupport {
- private static final long serialVersionUID = 4396125455881691845L;
- private static final Log logger = LogFactory.getLog(Policy.class);
- private List<User> users;
- @Element(value = User.class)
- private List users2;
- private Map<String, User> userMap;
- @Element(value = User.class)
- private Map userMap2;
- /* (non-Javadoc)
- * @see com.opensymphony.xwork2.ActionSupport#execute()
- */
- @Override
- public String execute() throws Exception {
- // -> aaa
- logger.info("users[0].name : " + users.get(0).getName());
- // -> bbb
- logger.info("users[1].name : " + users.get(1).getName());
- // -> ccc
- logger.info("users2[0].name : " + ((User)users2.get(0)).getName());
- // -> ddd
- logger.info("users2[1].name : " + ((User)users2.get(1)).getName());
- // -> [user1, user2]
- logger.info("userMap.key : " + userMap.keySet());
- // -> eee
- logger.info("userMap.key = " + "user1" + " : " + "userMap.value(user1's name) = " + userMap.get("user1").getName());
- // -> fff
- logger.info("userMap.key = " + "user2" + " : " + "userMap.value(user2's name) = " + userMap.get("user2").getName());
- // -> [user3, user4]
- logger.info("userMap2.key : " + userMap2.keySet());
- // -> ggg
- logger.info("userMap2.key = " + "user3" + " : " + "userMap.value(user3's name) = " + ((User)userMap2.get("user3")).getName());
- // -> hhh
- logger.info("userMap2.key = " + "user4" + " : " + "userMap.value(user4's name) = " + ((User)userMap2.get("user4")).getName());
- return super.execute();
- }
- // setters and getters
- }
public class OgnlConversionAction extends ActionSupport { private static final long serialVersionUID = 4396125455881691845L; private static final Log logger = LogFactory.getLog(Policy.class); private List<User> users; @Element(value = User.class) private List users2; private Map<String, User> userMap; @Element(value = User.class) private Map userMap2; /* (non-Javadoc) * @see com.opensymphony.xwork2.ActionSupport#execute() */ @Override public String execute() throws Exception { // -> aaa logger.info("users[0].name : " + users.get(0).getName()); // -> bbb logger.info("users[1].name : " + users.get(1).getName()); // -> ccc logger.info("users2[0].name : " + ((User)users2.get(0)).getName()); // -> ddd logger.info("users2[1].name : " + ((User)users2.get(1)).getName()); // -> [user1, user2] logger.info("userMap.key : " + userMap.keySet()); // -> eee logger.info("userMap.key = " + "user1" + " : " + "userMap.value(user1's name) = " + userMap.get("user1").getName()); // -> fff logger.info("userMap.key = " + "user2" + " : " + "userMap.value(user2's name) = " + userMap.get("user2").getName()); // -> [user3, user4] logger.info("userMap2.key : " + userMap2.keySet()); // -> ggg logger.info("userMap2.key = " + "user3" + " : " + "userMap.value(user3's name) = " + ((User)userMap2.get("user3")).getName()); // -> hhh logger.info("userMap2.key = " + "user4" + " : " + "userMap.value(user4's name) = " + ((User)userMap2.get("user4")).getName()); return super.execute(); } // setters and getters }
上面的代码中,我们可以看到,如果你使用泛型,那么你无需再使用任何额外的配置文件或者Annotation,XWork会把一切都为你准备好。如果你没有使用泛型,那么你可以使用Annotation来指定你需要进行转化的对象类型。其中,对Map对象使用Annotation时,Element中的value所对应的值,是Map中的value所对应的class。
由此可见,泛型和Annotation,在一定程度上,还是可以简化我们很多工作的。
文件上传
文件上传其实也是参数传递的一种,所以从方案上来讲,Struts2同样使用了一个拦截器来处理。而这个拦截器,同样来自于原来的Webwork,基本上没有做什么很大的改变。有关这个拦截器的详细内容,我们也留一个悬念,在后续章节中详细讲解。目前,你只要知晓,这个拦截器能帮助你完成一切文件上传相关的机制。
早在2005年,Quake Wang就对Webwork的文件上传机制有了详细的讲解:http://www.iteye.com/topic/10697
在这里我简单小结一下在进行文件上传时的三大要点:
1. 在配置文件上传时,拦截器的顺序非常关键
- <interceptor-stack name="uploadStack">
- <interceptor-ref name="upload"/>
- <interceptor-ref name="defaultStack"/>
- </interceptor-stack>
<interceptor-stack name="uploadStack"> <interceptor-ref name="upload"/> <interceptor-ref name="defaultStack"/> </interceptor-stack>
具体来说,upload的拦截器,必须在params的拦截器之前
2. 拦截器额外提供了一些额外的文件信息
FileName: 实际的文件名
在上面的action例子里, 那么有uploadFilesContentType和uploadFilesFileName这2个属性, 也能够被自动绑定
3. 拦截器提供的文件上传功能,你得到的是一个临时文件
而时代发展到Struts2的年代,对于文件上传的整体机制没有做
发表评论
-
Struts2几个常用标签的主要属性及示例(一)
2010-03-29 14:17 1009以前做过一个struts2的项目,总结了用到的几个struts ... -
Struts2标签库
2009-12-01 10:48 6471标签库,几乎是每个MVC ... -
Struts2的Result机制,让视图更丰富
2009-12-01 10:47 1614Struts2将Result列为一个独立的层次,可以说是整个S ... -
Struts2拦截器详解
2009-12-01 10:45 1871在之前的文章中,我们 ... -
Struts2MVC框架的困惑
2009-12-01 10:44 1158现在许许多多的初学者和程序员,都在趋之若鹜地学习Web开发的宝 ... -
Struts2配置详解
2009-12-01 10:43 854本篇文章让我们来详细探讨一下Struts2的配置文件的结构、配 ... -
Struts2的Action
2009-12-01 10:42 1021多数的MVC框架中的Control层,都是一个Java对象。按 ... -
Struts2使用OGNL
2009-12-01 10:40 1479OGNL是XWork引入的一个非常有效的数据处理的工具。我们已 ... -
Struts2的ONGL
2009-12-01 10:38 1897先让我们花费1分钟的时 ... -
Struts2配置
2009-12-01 10:37 1228几乎所有的开源框架都 ... -
Struts2深入plugin
2009-12-01 10:36 783Struts2提供了一种非常灵活的扩展方式,这种被称之为plu ... -
Struts2开发环境的搭建
2009-12-01 10:32 888工欲善其事,必先利其器。在我们深入Struts2之前,我还是想 ... -
Struts2的学习方法
2009-12-01 10:30 1066正确的学习方法不仅能 ...
相关推荐
NULL 博文链接:https://cdxs2.iteye.com/blog/1926357
我们知道,Struts2完成参数传递处理工作的基础是OGNL和ValueStack。而在这个 过程中,我也把Struts2所要做的工作大致归纳为两个方面: 1. 对OGNL操作进行封装,完成OGNL表达式所表示的值到Java对象的值传递机制 2. ...
利用AJAX传递JSON数组,后台struts2的action接收。 详细代码简单易懂。
在struts2中可以在方法上传递相应的参数,不需要使用注解,直接使用参数名进行界面传递参数信息,并且可以在界面进行访问
本文主要介绍Struts2中参数传递方法,希望能给大家做一个参考。
这是根据uploadify3 2结合struts2搭建的文件上传环境 可以直接导入eclipse运行 每步实现基本都加了注释 以下是我碰到的问题: 1 判断session是否失效 本实例没测试这个问题 但在工作项目中碰到了 但原因在这里...
刚开始学struts2时,自己写的小工程。
struts2 验证框架,彻底简化判断页面传递过来的参数,必学内容
而随着Struts2的流行,就应该研究一下在Struts2下如何利用JasperReports进行报表输出。本示例比较简单,采用的数据源即为JavaBean,而没有采用复杂的数据库,其实原理是一样的。只是传递给JasperReports的参数随着...
fileID:要取消的列队文件id 不传递参数时 表示取消列队中的第一个文件上传 传递星号 表示取消列队中的所有文件上传 suppressEvent:设置为true将禁止onUploadCancel事件 取值:String "true"|"事件...
第1章 Struts 2:现代Web框架 2 1.1 Web应用程序:快速学习 2 1.1.1 构建Web应用程序 2 1.1.2 基础技术简介 3 1.1.3 深入研究 6 1.2 Web应用程序框架 7 1.2.1 什么是框架 7 1.2.2 为什么使用框架 8 1.3 Struts 2框架...
struts2的资料以及struts的ui标签的使用,struts2如何和ajax进行参数传递
程序参考源代码 博文链接:https://honly-java.iteye.com/blog/1605764
内容: 1、OGNL —— 数据运转的催化剂 2、Result机制,让视图更丰富 ...5、Struts2中的参数传递 6、标签库,永恒的争论话题 7、拦截器详解 8、配置,灵活还是简单? 9、深入plugin 10、在Struts2中使用OGNL
uploadify+struts2+json 前台动态向后台传数据,并显示后台返回参数完成文件上传功能
struts result类型中redirect与redirectAction的使用 包括参数传递。
4、在action中把HttpServletRequest参数和HttpServletResponse参数传递过去。 5、在过滤器中通过java的反射机制调用action。 6、详细过程参照cn.itcast.action包中的内容 3Struts2介绍 1、struts2是apache组织发明的...
内容包括ognl,result机制,struts2配置详解,struts2中的action,struts2中的参数传递,标签库,拦截器的详解,深入plugin
3.3 把静态参数传递给一个动作 41 3.4 ActionSupport类 41 3.5 结果 42 3.5.1 Chain 43 3.5.2 Dispatcher 44 3.5.3 FreeMarker 44 3.5.4 HttpHeader 44 3.5.5 Redirect 45 3.5.6 Redirect Action 46 3.5.7 ...
刚完成的 日本的项目 struts2 jdom解析 远端服务器 xml 文件 自定义struts2 标签分页 分页只需要向 其 传递2参数 页面上 自定义的标签 自动分页