当前位置: 代码迷 >> J2EE >> Servlet.service() for servlet jsp threw exception 和No bean named 'sessionFactory' is defined,该怎么处理
  详细解决方案

Servlet.service() for servlet jsp threw exception 和No bean named 'sessionFactory' is defined,该怎么处理

热度:777   发布时间:2016-04-22 01:23:15.0
Servlet.service() for servlet jsp threw exception 和No bean named 'sessionFactory' is defined
配置SSH时候遇到的,准备做个登陆!!
————————
这是配置的applicationContext
Java code
 
<bean id="Mysql" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="com.mysql.jdbc.Driver">
</property>
<property name="url"
value="jdbc:mysql://127.0.0.1:3306/dating">
</property>
<property name="username" value="root"> </property>
<property name="password" value="root"> </property>
</bean>


<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="Mysql" />
</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="mappingResources">
<list>
<value>cn/studclub/vo/User.hbm.xml </value>
</list>
</property>
</bean>

<bean id="userDao" class="cn.studclub.impl.UserDaoImpl" >
<property name="sessionFactory" ref="sessionFactory" />
</bean>

web.xml

Java code
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.4"     xmlns="http://java.sun.com/xml/ns/j2ee"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee     http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">  <welcome-file-list>    <welcome-file>index.jsp</welcome-file>  </welcome-file-list>    <servlet>    <servlet-name>action</servlet-name>    <servlet-class>org.apache.struts.action.ActionServlet</servlet-class>    <init-param>      <param-name>config</param-name>      <param-value>/WEB-INF/struts-config.xml</param-value>    </init-param>    <init-param>      <param-name>debug</param-name>      <param-value>2</param-value>    </init-param>    <init-param>      <param-name>detail</param-name>      <param-value>2</param-value>    </init-param>    <load-on-startup>2</load-on-startup>  </servlet>  <!-- Standard Action Servlet Mapping -->  <servlet-mapping>    <servlet-name>action</servlet-name>    <url-pattern>*.do</url-pattern>  </servlet-mapping>      <context-param>      <param-name>contextConfigLocation</param-name>      <param-value>classpath*:applicationContext.xml</param-value>  </context-param>      <listener>        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>   </listener>     <filter>    <filter-name>Spring character encoding filter</filter-name>    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>    <init-param>        <param-name>encoding</param-name>        <param-value>GBK</param-value>    </init-param>  </filter>  <filter-mapping>    <filter-name>Spring character encoding filter</filter-name>    <url-pattern>/*</url-pattern>  </filter-mapping>    <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> </web-app>
  相关解决方案