辅导:JAVA基础(SSH2配置要点)
来源:优易学  2011-10-14 15:36:04   【优易学:中国教育考试门户网】   资料下载   IT书店
  一、在WEB-INF.xml中
  <?xml version="1.0" encoding="UTF-8"?>
  <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
  http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <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>struts2</filter-name>
  <filter-class>
  org.apache.struts2.dispatcher.FilterDispatcher
  </filter-class>
  </filter>
  <filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
  </filter-mapping>
  <welcome-file-list>
  <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  </web-app>
  二、在applicationContext.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"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
  <bean id="dataSource"
  class="org.apache.commons.dbcp.BasicDataSource">
  <property name="driverClassName" value="com.mysql.jdbc.Driver" />
  <property name="url" value="jdbc:mysql://localhost:3306/user" />
  <property name="username" value="root" />
  <property name="password" value="" />
  </bean>
  <bean id="sessionFactory"
  class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
  <property name="dataSource">
  <ref local="dataSource" />
  </property>
  <property name="annotatedClasses">
  <list>
  <value>bean.User</value>
  </list>
  </property>
  <property name="hibernateProperties">
  <props>
  <prop key="hibernate.dialect">
  org.hibernate.dialect.MySQLDialect
  </prop>
  <prop key="hibernate.show_sql">true</prop>
  <prop key="hibernate.c3p0.minPoolSize">5</prop>
  <prop key="hibernate.c3p0.maxPoolSize">10</prop>
  <prop key="hibernate.c3p0.max_statement">50</prop>
  </props>
  </property>
  </bean>
  </beans>
  三、在持久化类中,继承
  org.springframework.orm.hibernate3.support.HibernateDaoSupport

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训