hibernate spring sturts2配置

时间:2023-03-08 23:29:11
hibernate spring sturts2配置
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration
PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory > <property name="hibernate.connection.url">
jdbc:oracle:thin:@10.166.46.213:1521:ora11g
</property> <property name="hibernate.connection.driver_class">
oracle.jdbc.driver.OracleDriver
</property> <property name="hibernate.connection.username">
forum
</property> <property name="hibernate.connection.password">
forum
</property> <property name="password.encrypted">
false
</property> <property name="hibernate.show_sql">
false
</property> <property name="hibernate.use_outer_join">
True
</property> <property name="hibernate.transaction.factory_class">
org.hibernate.transaction.JDBCTransactionFactory
</property> <property name="c3p0.min_size">5</property>
<property name="c3p0.max_size">20</property>
<property name="c3p0.timeout">1800</property>
<property name="c3p0.max_statements">50</property> </session-factory> </hibernate-configuration>

放在src目录下hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd"> <struts>
<package name="defaultaction" extends="default-base">
<action name="show"
class="com.jforum.action.ShowAction" method="show">
<result name="show">success.html</result>
</action>
</package> <package name="default-base" extends="struts-default" >
<global-results>
<result name="tologinPage">forum/login.jsp</result>
<result name="error">forum/error.jsp</result>
</global-results>
</package>
</struts>

放在 src目录下struts.xml

WEB-INF目录下 applicationContext.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- 指定Spring配置文件的Schema信息 -->
<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:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location">
<value>/WEB-INF/jdbc.properties</value>
</property>
</bean> <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<property name="url"
value="jdbc:oracle:thin:@10.166.46.213:1521:ora11g" />
<property name="username" value="forum" />
<property name="password" value="forum" />
<!-- 连接池启动时的初始值 -->
<property name="initialSize" value="1" />
<!-- 连接池的最大值 -->
<property name="maxActive" value="500" />
<!-- 最大空闲值,当经过一个高峰期后,连接池可以慢慢将已经用不到的连接进行释放,一直达到maxIdel为止 -->
<property name="maxIdle" value="2" />
<!-- 最小空闲值,当空闲的连接小于阀值时,连接池会去预审一些连接,以免洪峰来时来不及去申请 -->
<property name="minIdle" value="1" />
</bean> <!-- 配置Hibernate -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="mappingResources">
<list>
<value>com/jforum/domain/Address.hbm.xml</value>
<value>com/jforum/domain/Employee.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop>
</props>
</property>
</bean>
<bean id="txManger"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean> <tx:annotation-driven transaction-manager="txManger" /> <bean id="employeeDao" class="com.jforum.dao.impl.EmployeeDaoImpl">
<property name="sessionFactory" ref="sessionFactory" />
</bean> <!--
<bean id="studentService" class="ssh.serviceImpl.StudentServiceImpl">
<property name="studentDao" ref="studentDao"></property>
</bean> <bean id="signService" class="ssh.serviceImpl.SignInServiceImpl"></bean> <bean id="loginAction" class="ssh.action.LoginAction">
<property name="signInService" ref="signService">
</property>
</bean> <bean id="siginAction" class="ssh.action.SiginAction">
<property name="studentService" ref="studentService">
</property>
</bean>
--> </beans>

jdbc.properties

datasource.driverClassName=oracle.jdbc.driver.OracleDriver
datasource.url=jdbc:oracle:thin:@10.166.46.213:1521:ora11g
datasource.username=forum
datasource.password=forum
datasource.defaultAutoCommit=true
hibernate.dialect=org.hibernate.dialect.Oracle9Dialect

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>sshtest</display-name> <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/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.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter> <filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.htm</welcome-file>
</welcome-file-list> </web-app>

锋利的jquery

jquery实战