struts2参数传递:Struts2中的参数传递

  我们知道Struts2完成参数传递处理工作基础是OGNL和ValueStack而在这个过程中我也把Struts2所要做工作大致归纳为两个方面:

  1. 对OGNL操作进行封装完成OGNL表达式所表示值到Java对象值传递机制

  2. 在参数传递过程中做恰当类型转化保证页面上串能够转化成各式各样Java对象

  接下来通过 4个区别角度来具体讲述Struts2在这两个方面工作

  目 录 [ - ]

  最简单参数传递

  Array、List、Map等容器类型参数传递

  文件上传

  自定义类型转化实现

  最简单参数传递

public 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
   * specied.
   *
   * @param context - OGNL context under which the conversion is being done
   * @param o    - the object to be converted
   * @param toClass - the that contains the code to convert to enumeration
   * @ 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) {
     (o instanceof String) {
       convertFromString(((String) o)[0], toClass);
    } (o instanceof String) {
       convertFromString((String) o, toClass);
    }
     super.convertValue(context, o, toClass);
  }
  /**
   * Converts _disibledevent="Struts2中参数传递" />

/**
* context - OGNL context under which the conversion is being done
* target - target object in which the property is being
* member - member (Constructor, Method or Field) being
* propertyName - property name being
* value - value to be converted
* toType - type to which value is converted
*/
public Object convertValue(Map context, Object target, Member member, String propertyName, Object value, Class toType);


Tags:  struts2spring struts2 struts2参数 struts2参数传递

延伸阅读

最新评论

发表评论