<?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/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd"> <!-- 配置数据源 -->
<bean id="dataSource"
       class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"> 
    <value>net.sourceforge.jtds.jdbc.Driver</value>
</property> 
<property name="url"> 
    <value>jdbc:jtds:sqlserver://127.0.0.1:1433;DatabaseName=bjpg_cms</value> 
</property> 
<property name="username">
    <value>sa</value> 
</property> 
<property name="password"> 
    <value>sa</value> 
</property>
</bean>
<!-- 配置SessionFactory -->
<bean id="sessionFactory" 
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="mappingResources">
<list>
<value>cn/hxex/cms/model/SysMenu.hbm.xml</value>
<value>cn/hxex/cms/model/SysUsers.hbm.xml</value>
</list>
</property>

<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.SQLServerDialect
</prop>
<prop key="hibernate.show_sql">true</prop> </props>
</property>

<property name="dataSource">
<ref bean="dataSource"/>
</property>
</bean> <bean id="sysMenudao"
class="cn.hxex.cms.dao.hibernate.SysMenuDAO">
<property name="sessionFactory"><ref local="sessionFactory"/></property>
</bean>
</beans>

解决方案 »

  1.   

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/classes/applicationContext.xml</param-value>
    </context-param>
    <filter>
    <filter-name>hibernateFilter</filter-name>
    <filter-class>
    org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
    </filter-class> </filter>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <filter-mapping>
    <filter-name>hibernateFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>

    <servlet>
      <servlet-name>SpringContextServlet</servlet-name>
      <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>   
      <load-on-startup>1</load-on-startup>
    </servlet>

    <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>

    <error-page>
    <exception-type>
    cn.hxex.cms.exception.BlogDAOException
    </exception-type>
    <location>/error/daoerror.jsp</location>
    </error-page></web-app>