关于web项目添加struts1 与spring2.0支持的问题

单独添加struts1支持页面访问没有问题 但在添加spring2.0支持的时候 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;

public UserInfoService getUserInfoService() {
return userInfoService;
}

public void setUserInfoService(UserInfoService userInfoService) {
this.userInfoService = userInfoService;
}
 此service 为null 求解 后台报空指针错误
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值