`
shelleyhacker
  • 浏览: 15846 次
  • 性别: Icon_minigender_1
  • 来自: 南京
文章分类
社区版块
存档分类
最新评论

S2SH 初步整合遇到一系列问题,高手飘过,成长经历 !!!

阅读更多
<1>S2SH web.xml内加载beans.xml配置出现了找不到jdbc.properties文件,问题如下: 
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanInitializationException: Could not load properties; nested exception is java.io.FileNotFoundException: Could not open ServletContext resource [/jdbc.properties]
          ...
Caused by: java.io.FileNotFoundException: Could not open ServletContext resource [/jdbc.properties]

web.xml内配置监听器加载:
   <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>-->
  <param-value>classpath:beans.xml</param-value>
  </context-param>
第一反应是<param-value>内的值,即struts默认加载为WEB-INF下的一些配置文件,但是我不可能把jdbc.properties写到<param-value>内,找到beans.xml 找到
<beanclass="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
        <value>jdbc.properties</value> 
    </property>
</bean>

修改为:classpath:jdbc.properties 问题解决。

<2> 在struts2与spring整合的时候,struts2在初始化时候对相应的Action内部属性进行注入(从spring容器内进行匹配)操作,而sturts2-spring-pligin里struts.objectfactory.spring.autowire 内装配是默认以名称来: 
   故Action在spring容器内的名称尽量不要与其某属性的名称相同,否则会出现无法转换诡异错误。

  实际上Action对象的产生是由strut2的 sturts2-spring-plugin 来管理的,但是其内部属性如UserManager之类是由插件从spring容器内部注入的,强制性 。。。也即strut2这边也有个专门存放Action的容器 ,由插件产生。。。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics