花了2个小时终于配置好struts2.0.6+spring2.0.3+hibernane3,为自己庆祝一下,分享一下经验
一、配置Struts2
跟webwork配置基本一致,主要是struts2.properties和struts.xml 2个配置文件,我的struts2.properties如下配置:
struts.xml 就是配置action了,由于设定了struts.objectFactory = spring,因此struts2会自动将action转为spring的bean,struts.xml可以直接配置我们的action路径,在action中我们只需要设置某个service文件的set方法即可调用事务管理bean。
<!--sp-->xml version="1.0" encoding="UTF-8" ?> <!--CTYPE struts PUBLIC </sp--> "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"> <struts> <include file="struts-default.xml" /> <package name="default" extends="struts-default"> <default-interceptor-ref name="completeStack" /> <global-results> <result name="login" type="redirect">login!default.actionresult> <result name="unauthorized">unauthorized.jspresult> global-results> <action name="login" class="com.baseframe.action.LoginAction"> <result name="input">login.jspresult> <result name="success">main.jspresult> <result name="error">login.jspresult> action> <action name="logout" class="com.baseframe.action.LogoutAction"> <result name="success">login.jspresult> action> package> struts>