ssh整合

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc\:mysql\://localhost\:3306/hsjShop?useUnicode\=true&characterEncoding\=utf-8
jdbc.user=root
jdbc.password=123456
<?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>
    <constant name="struts.i18n.encoding" value="UTF-8" />
    <!-- 用不用浏览器缓存 开发阶段不用 上线的时候用 -->
    <constant name="sturts.server.static.browerCache" value="false" />
    <!-- 当struts配置做了修改的时候不需要重启服务器,开发阶段设成true 上线的时候设成false -->
    <constant name="struts.configuration.xml.reload" value="true" />
    <!--设成开发模式,开发模式的时候如果出错了页面上会提示更加详细的错误信息,开发的时候设成true上线的时候设成false -->
    <constant name="struts.devMode" value="true" />

    <!-- 该属性设置struts2是否支持动态方法调用,该属性的默认值是true。如果需要关闭动态方法调用,则可设置该属性为false -->
    <constant name="struts.enable.DynmicMethodInvocation" value="false" />





    <package name="default" namespace="/" extends="struts-default,json-default">

        <!-- 与user有关的action -->
        <action name="user_*" class="com.smw.action.UserAction" method="{1}">
            <result name="registUi">WEB-INF/smw/user/regist.jsp</result>
            <result name="regist" type="redirectAction">home_showHome</result>
            <result name="checkerror">WEB-INF/smw/user/regist.jsp</result>
            <result name="loginUi">WEB-INF/smw/user/login.jsp</result>
            <result name="success" type="redirectAction">home_showHome</result>
            <result name="erorr">WEB-INF/smw/user/login.jsp</result>
            <result name="checkerror2">WEB-INF/smw/user/login.jsp</result>
            <result name="loginout" type="redirectAction">home_showHome</result>

            <result name="json" type="json">
                <param name="root">result</param>
            </result>
        </action>
    </package>
    <!-- 去掉样式标签 -->
    <!-- <constant name="struts.ui.theme" value="simple" /> <constant name="struts.ui.templateDir" 
        value="template" /> <constant name="struts.ui.templateSuffix" value="ftl" 
        /> -->
</struts>

Hibernate

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="dialect">
            <!-- org.hibernate.dialect.Oracle10gDialect -->
             org.hibernate.dialect.MySQL5InnoDBDialect
        </property>

        <property name="hbm2ddl.auto">update</property>
        <property name="show_sql">true</property>
        <property name="format_sql">true</property>

        <!-- -->

        <mapping resource="com/smw/pojo/User.hbm.xml" />
    </session-factory>
</hibernate-configuration>

spring
spring-dao.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"
        xmlns:p="http://www.springframework.org/schema/p"
        xmlns:context="http://www.springframework.org/schema/context"
        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.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context.xsd
            http://www.springframework.org/schema/aop
            http://www.springframework.org/schema/aop/spring-aop.xsd
            http://www.springframework.org/schema/tx
            http://www.springframework.org/schema/tx/spring-tx.xsd
            ">

        <!-- 配置properties(整合Hibernate) -->
        <context:property-placeholder location="classpath:jdbc.properties"/>
        <!-- 配置数据源 -->
        <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
            <!-- 数据库连接信息 -->
            <property name="jdbcUrl" value="${jdbc.url}"/>
            <property name="driverClass" value="${jdbc.driver}"/>
            <property name="user" value="${jdbc.user}"/>
            <property name="password" value="${jdbc.password}"/>
            <!-- 其他配置 -->
            <property name="initialPoolSize" value="3" />
            <property name="maxPoolSize" value="5" />
            <property name="minPoolSize" value="3" />
            <property name="acquireIncrement" value="2" />
            <property name="maxStatements" value="8" />
            <property name="maxStatementsPerConnection" value="5" />
            <property name="maxIdleTime" value="20" />
        </bean>

        <!-- 配置会话工厂 sessionFactory -->
        <bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
            <property name="dataSource" ref="dataSource"/>
            <!-- 指定hibernate配置文件的的位置 -->
            <property name="configLocation" value="classpath:hibernate.cfg.xml" />
        </bean> 
</beans>

spring-service.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"
        xmlns:p="http://www.springframework.org/schema/p"
        xmlns:context="http://www.springframework.org/schema/context"
        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.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context.xsd
            http://www.springframework.org/schema/aop
            http://www.springframework.org/schema/aop/spring-aop.xsd
            http://www.springframework.org/schema/tx
            http://www.springframework.org/schema/tx/spring-tx.xsd
            ">
        <!-- 声明式事务管理 -->
        <bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
            <property name="sessionFactory" ref="sessionFactory"></property>
        </bean>
</beans>

spring-mvc.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"
        xmlns:p="http://www.springframework.org/schema/p"
        xmlns:context="http://www.springframework.org/schema/context"
        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.xsd
            http://www.springframework.org/schema/context
            http://www.springframework.org/schema/context/spring-context.xsd
            http://www.springframework.org/schema/aop
            http://www.springframework.org/schema/aop/spring-aop.xsd
            http://www.springframework.org/schema/tx
            http://www.springframework.org/schema/tx/spring-tx.xsd
            ">
        <!-- 开启包扫描 -->
        <context:component-scan base-package="com.smw.*"/>

        <import resource="classpath*:spring-dao.xml"/>
        <import resource="classpath*:spring-service.xml"/>

        <!-- 配置基于注解的事务支持-->
        <tx:annotation-driven transaction-manager="transactionManager"/>
</beans>

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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>smw_web</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>

  <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:spring-mvc.xml</param-value>
    </context-param>
    <!-- 配置一个openSessionView用来处理懒加载异常,将session生命周期扩大到action的开始和结束 -->
    <filter>
        <filter-name>OpenSessionInView</filter-name>
        <filter-class>org.springframework.orm.hibernate5.support.OpenSessionInViewFilter</filter-class>
    </filter>
    <!-- 加入struts的核心控制器 -->
    <filter>
        <filter-name>smw_web</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>OpenSessionInView</filter-name>
        <url-pattern>*.action</url-pattern>
    </filter-mapping>

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



</web-app>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值