Spring几个问题解决办法

1、spring framework 4.02最新版下载地址:

http://repo.springsource.org/libs-release-local/org/springframework/spring 

2、Attribute 'singleton' is not allowed to appear in element 'bean' 问题:
Spring 1.*
<bean id="hibernateSessionFactory" class="org.hibernate.admin.component.HibernateSessionFactory" init-method="init" destroy-method="dispose" singleton="true">
Spring 2.0以上:
spring-beans-2.0.dtd/xsd does not support singleton="true"/"false" anymore. Use scope="singleton/"prototype" instead!
<bean id="hibernateSessionFactory" class="org.hibernate.admin.component.HibernateSessionFactory" init-method="init" destroy-method="dispose" scope="singleton">

3、struts2与spring整合时,报空指针NullPointerException异常的解决:
在spring配置文件中对于action的配置,假设id是useraction,那么在struts.xml中,不应该还是像以前单独用struts时那样,而是将在struts.xml中action的class=useraction。也就是: 将struts.xml中的action的class属性,由class名改为Spring中定义的bean的id名。 
applicationContext.xml:
<bean id="login" class="com.action.LoginAction" scope="singleton"> 
      <property name="log" ref="loginBusiness"/>
</bean> 
struts.xml :
<action name="Login" class="login"> <!-- com.action.LoginAction -->
            <result>/loginResult.jsp</result>
            <result name="input">/login.jsp</result>
  </action>

4、Cannot locate the chosen ObjectFactory implementation解决
添加struts2-spring-plugin-2.3.15.3.jar,
把struts.xml配置中的    <constant name="struts.objectFactory" value="spring" />
改成   <constant name="com.opensymphony.xwork2.ObjectFactory" value="spring" />
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值