spring无法注入

struts2整合spring3启动不报错并且Spring成功初始化 :信息: Initializing Spring root WebApplicationContext

但是在action里面无法使用spring无法注入的dao或者service。

解决办法:

1、没加入struts2-spring-plugin.jar包

2、检查配置文件是否真的没有问题

3、在struts.xml里面将action配置的class路径修改成 在application.xml配置的对应action的id属性

修改前:

[html] view plain copy
  1. <struts>
  2. <packagename="budget"extends="struts-default">
  3. <actionname="login"class="com.bean.LoginAction"method="verifyUser">
  4. <resultname="success">finance_center/center.jsp</result>
  5. <resultname="error">login/error.jsp</result>
  6. </action>
  7. </struts>

修改后:

[html] view plain copy
  1. <struts>
  2. <packagename="budget"extends="struts-default">
  3. <actionname="login"class="loginAction"method="verifyUser">
  4. <resultname="success">finance_center/center.jsp</result>
  5. <resultname="error">login/error.jsp</result>
  6. </action>
  7. <struts>

spring配置文件不变

 
   
[html] view plain copy
  1. <beanid="loginAction"class="com.action.LoginAction"scope="prototype">
  2. <propertyname="service">
  3. <refbean="loginService"/>
  4. </property>
  5. </bean>

第三个原因很坑爹啊。。。费力我两个小时啊。。。。。。。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值