ssh整合配置文件
程序员文章站
2022-04-30 09:42:10
...
<?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:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/blog</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>123456</value>
</property>
</bean>
<!-- 添加sessionFactory bane ,注意,该类是Spring提供的 -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- 把数据源 bean 注入到sessionFactory的dataSource属性 -->
<property name="dataSource">
<ref local="dataSource" />
</property>
<!-- 引入映射文件,如果有多个可以继续添加 <value> -->
<property name="mappingResources">
<list>
<value>dps/bean/User.hbm.xml</value>
</list>
</property>
<!-- hibernate的基本配置,如:方言,是否显示sql等 -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</prop>
<prop key="hbm2ddl.auto">update</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="format_sql">true</prop>
</props>
</property>
</bean>
<bean id="userDaoTarget" class="dps.dao.impl.UserDaoImpl">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<bean id="userService"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="target" ref="userDaoTarget"></property>
<property name="transactionManager" ref="transactionManager"></property>
<property name="transactionAttributes">
<props>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
</bean>
<!-- Struts中使用的Bean -->
<bean id="userAction" class="dps.action.UserAction">
<property name="userDao" ref="userService"></property>
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>
<package name="myPackage" extends="struts-default" >
<!-- 用户登录 -->
<action name="login" class="userAction" method="login">
<result name="success">/index.jsp</result>
<result name="input">/Login.jsp</result>
</action>
<!-- 用户注册 -->
<action name="regist" class="userAction" method="regist">
<result name="success">/Login.jsp</result>
</action>
<!-- 列出所有用户 -->
<action name="listAllUser" class="userAction" method="listAllUser">
<result name="success">/listAllUser.jsp</result>
</action>
<!-- 列出所有用户 分页 -->
<action name="listAllUserPage" class="userAction" method="listAllUserPage">
<result name="success">/listAllUser.jsp</result>
</action>
<!-- 根据查询条件查询用户 分页 -->
<action name="searchUser" class="userAction" method="searchUser">
<result name="success">/listAllUser.jsp</result>
</action>
<!-- 到用户修改界面 -->
<action name="preUpdate" class="userAction" method="preUpdate">
<result name="success">/update.jsp</result>
</action>
<!-- 修改用户 -->
<action name="update" class="userAction" method="update">
<result name="success" type="redirectAction">listAllUserPage</result>
</action>
<!--删除用户 -->
<action name="delete" class="userAction" method="delete">
<result name="success" type="redirectAction">listAllUserPage</result>
</action>
</package>
</struts>