springmvc的参数绑定有以下几种方法 : 1)默认的参数绑定 Request Response Session Model(实现ModelMap) 2)简单类型参数绑定 方法的形参上(Integer id,String,Double,Boolean) 3)pojo类型 4)包装类型
          springmvc的参数绑定有以下几种方法:
1)默认的参数绑定 Request Response Session Model(实现ModelMap)
2)简单类型参数绑定 方法的形参上(Integer id,String,Double,Boolean)
3)pojo类型
4)包装类型 QueryVo
5)参数绑定之自定义参数转换
高级参数绑定
1)绑定数组
直接在方法的参数上绑定 xxx[] xxx
将数组注入对象,用该对象来接受数组
2)绑定list
使用包装类,包装类中有list集合
自定义参数转换的步骤
1、在springmvc.xml中配置Conveter转换器
<bean id="conversionServiceFactoryBean" class="org.springframework.format.support.FormattingConversionServiceFactoryBean">
  <!-- 配置 多个转换器-->
  <property name="converters">
    <list>
      <bean class="com.itheima.springmvc.conversion.DateConveter"/>
    </list>
  </property>
</bean>
2、定义转换类,实现Conveter接口
DateConveter 类:
public class DateConveter implements Converter<String, Date>{
  public Date convert(String source) {
    // TODO Auto-generated method stub
    try {
      if(null != source){//2016:11-05 11_43-50
        DateFormat df = new SimpleDateFormat("yyyy:MM-dd HH_mm-ss");
        return df.parse(source);
      }
    } catch (Exception e) {
      // TODO: handle exception
    }
    return null;
  }
}
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持易盾网络。
