struts2.3+spring3.2+hibernate4.2例子
有些教程比较老,可是版本更新不等人,基于马士兵老师小例子,自己重新引用了新的包,调试确实有点烦人,但是通过英文文档和google解决问题。官网的更新超快,struts2.3+spring3.2+hibernate4.2很快更新至此,不久又有spring4,其实怎么变都差不多,多一点东西。
给个资源,struts2.3+spring3.2+hibernate4.2整合包:http://download.csdn.net/detail/iaiti/6234853
小例子:http://download.csdn.net/detail/iaiti/6240459
Hibernate4没了HibernateTemplate令我一头雾水,Hibernate4已经可以完全实现事务管理,所以还是用你的session吧。
MySql建新的数据库,spring;建一个新表:user
<filter><filter-name>openSessionInView</filter-name><filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class></filter><filter-mapping><filter-name>openSessionInView</filter-name><url-pattern>/*</url-pattern></filter-mapping>
不然就不要load用get,因为session要关的。
接着又有经典错误出现: Connection cannot be null when 'hibernate.dialect' not set,写个Hibernate.properties解决。应该是util的包自己写了个static的sessionFactory冲突,个人猜测。
得知spring的开发者不仅拿着计算机的学位,还拿着音乐博士学位,真厉害。