struts.xml
<constant name=”struts.objectFactory” value=”spring“></constant>
<!– struts2的扩展名,比如struts1的时候,用的.do,struts2默认为.action,可以改成其它的,比如.dxd –>
<constant name=”struts.action.extension” value=”action”></constant>
<!– 资源文件 –>
<constant name=”struts.custom.i18n.resources” value=”messageResource”></constant>
<package name=”register1″ namespace=”/” extends=”struts-default”>
<action name=”showIndex”>
<result name=”success”>/WEB-INF/pages/index.jsp</result>
</action>
<action name=”register” class=”registerAction” method=”addUser”>
<result name=”success”>/WEB-INF/pages/welcome.jsp</result>
<result name=”input”>/WEB-INF/pages/error.jsp</result>
</action>
</package>
applicationContext.xml
<bean id=”registerAction” class=”com.broada.demo.action.RegisterAction” scope=”prototype”>
<property name=”userserviceImpl” ref=”userserviceId”></property>
</bean>
<bean id=”userdaoId” class=”com.broada.demo.daoImpl.UserDaoImpl”>
<property name=”sqlMapClient” ref=”sqlMapClient”></property>
</bean>
<bean id=”userserviceId” class=”com.broada.demo.serviceImpl.UserServiceImpl”>
<property name=”userdaoImpl” ref=”userdaoId”/>
</bean>
<bean id=”sqlMapClient” class=”org.springframework.orm.ibatis.SqlMapClientFactoryBean”>
<property name=”configLocation”>
<value>/WEB-INF/ibatis/SqlMapConfig.xml</value>
</property>
<property name=”dataSource”>
<ref bean=”dataSource”/>
</property>
</bean>
web.xml
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/applicationContext-*.xml</param-value>
</context-param>
<!– struts2模块 –>
<filter>
<filter-name>struts2</filter-name>
<!– struts2的核心过滤器 –>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
控制台报错
2014-9-30 13:49:49 org.apache.struts2.dispatcher.Dispatcher error
严重: Exception occurred during processing request: Unable to instantiate Action, registerAction, defined for “”login”” in namespace “”/””registerAction
Unable to instantiate Action, registerAction, defined for “”login”” in namespace “”/””registerAction