日期:2014-05-20  浏览次数:20751 次

spring 和 struts 集成问题
大家好:jbuilder2005中把struts和soring集成起来(简单的)但总是报错,请求帮助。

application_context.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
  http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
  http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">

  <bean id="userManager" class="UserManager.UserManagerImpl"/>
</beans>


------解决方案--------------------
你是不是把struts交给spring托管了?


------解决方案--------------------
探讨
这个错误很明显.你的spring 配置的时候需要sessionfactry的支持
你紧紧配置了一个bean而没有配置sessionfactory
正确配置
<bean id="userManager" class="UserManager.UserManagerImpl"/>
<property name="sessionFactory" ref="sessionFactory" />//应该加上这一项
</bean>
还需要加一个这样的bean
<!-- 配置sessionFactory -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFac…

------解决方案--------------------
另外你的web.xml文件中应该加一如下过滤器
<filter>
<filter-name>hibernateFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>hibernateFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
这样可以你的session就可以满足hibernate延迟加载的问题.
你要学的还很多哦兄弟,加油!!
------解决方案--------------------
你这个的错误是没有在web.xml里面读spring文件
应该加这项配置
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext-*.xml</param-value>
</context-param>