Spring
共 5 篇文章
Spring3 mvc controller映射date类型
spring3 mvc 的controller方法如果有参数会自动映射传入的来的parameter,但是一个date类型的值传进来会被认为是string类型,如果你需要映射至一个date字段,就会报类型不匹配的exception.如果是spring2.5即需通过extends simpleFormController override initBinder方法,注册一个自定义的CustomEditor.但spring3里,这个simpleformController被@Deprecated了,取而代之的是注解的方式即: @InitBinder protected void initBinde…
2014-08-19 15:29 · Spring
Spring中ref local与ref bean区别
< bean id = "userDAOProxy" class = "org.springframework.transaction.interceptor.TransactionProxyFactoryBean" > < property name = "transactionManager" > < ref bean = "transactionManager" /> </ property > < property name = "target" > < ref local = "UserDAO" /> </ property > </ bean > 1 、用 local 属性指定目…
2013-10-16 15:00 · Spring
HibernateTemplate的一些常用方法总结
1:get/load存取单条数据 public Teacher getTeacherById(Long id) { return (Teacher)this.hibernateTemplate.get(Teacher.class, id); } public Teacher getTeacherById(Long id) { return (Teacher)this.hibernateTemplate.load(Teacher.class, id); } 2:find/iterate查询操作 public Iterator getTeachersByAge(int age) { Iterat…
Spring 中的BeanUtils与apache中的BeanUtils区别
org.apache.commons.beanutils.BeanUtils#copyProperties方法会进行类型转换,默认情况下会将Ineger、Boolean、Long等基本类型包装类为null时的值复制后转换成0或者false,有时这个可能会引起不必要的麻烦。 而org.springframework.beans.BeanUtils.copyProperties(bookDto, book);则不会!
2011-08-12 18:38 · Spring
实例化Spring容器常用的两种方式:
实例化Spring容器常用的两种方式: 方法一: 在类路径下寻找配置文件来实例化容器 ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{"beans.xml"}); 方法二: 在文件系统路径下寻找配置文件来实例化容器 ApplicationContext ctx = new FileSystemXmlApplicationContext(new String[]{“d:\\beans.xml“}); Spring的配置文件可以指定多个,可以通过String数组传入。 例如 ApplicationC…
2011-08-08 14:48 · Spring