单独添加struts1支持页面访问没有问题 但在添加spring2.0支持的时候 action中 并没有注入成功 求大大指点下问题 感激不尽!
struts-config.xml
applicationContext.xml
web.xml
spring jar包
log4j-1.2.15.jar, servlet-api.jar, spring.jar, spring-web.jar, spring-webmvc.jar
struts1 jar包
antlr.jar commons-beanutils.jar commons-collections.jar commons-digester.jar
commons-fileupload.jar commons-logging.jar commons-validator.jar jakarta-oro.jar
struts.jar
java 文件就不一一列出了 应该没有问题 都是简单的action 与实体类
action 中
struts-config.xml
<struts-config>
<form-beans>
<form-bean name="userInfoForm" type="form.UserInfoForm" />
</form-beans>
<global-forwards>
<forward name="index" path="/WEB-INF/jsp/index.jsp" />
</global-forwards>
<action-mappings>
<action path="/login" type="action.LoginAction" parameter="method" name="userInfoForm" scope="request" >
<forward name="success" path="/WEB-INF/jsp/login.jsp" />
<forward name="error" path="/WEB-INF/jsp/error.jsp" />
</action>
</action-mappings>
</struts-config>
applicationContext.xml
<bean id="mvc.userInfo" class="bo.UserInfo" />
<bean id="mvc.userInfoService" class="service.impl.UserInfoServiceImpl">
<property name="userInfo" ref="mvc.userInfo"></property>
</bean>
<bean id="action.loginAction" class="action.LoginAction">
<property name="userInfoService" ref="mvc.userInfoService"></property>
</bean>
<bean id="form.userInfoForm" class="form.UserInfoForm">
<property name="userInfo" ref="mvc.userInfo"></property>
</bean>
web.xml
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml </param-value>
</context-param>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
spring jar包
log4j-1.2.15.jar, servlet-api.jar, spring.jar, spring-web.jar, spring-webmvc.jar
struts1 jar包
antlr.jar commons-beanutils.jar commons-collections.jar commons-digester.jar
commons-fileupload.jar commons-logging.jar commons-validator.jar jakarta-oro.jar
struts.jar
java 文件就不一一列出了 应该没有问题 都是简单的action 与实体类
action 中
private UserInfoService userInfoService;此service 为null 求解 后台报空指针错误
public UserInfoService getUserInfoService() {
return userInfoService;
}
public void setUserInfoService(UserInfoService userInfoService) {
this.userInfoService = userInfoService;
}