Ssh整合文件:
1.applicationContext.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"xmlns:tx="http://www.springframework.org/schema/tx"
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.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
">
<!-- 包含其他文件 -->
<import resource="classpath:applicationContext-dao.xml"/>
<import resource="classpath:applicationContext-service.xml"/>
<import resource="classpath:applicationContext-action.xml"/>
<!-- 加载db.properties文件 -->
<context:property-placeholder location="classpath:db.properties"
system-properties-mode="NEVER" />
<!-- 配置连接池对象 -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"
init-method="init" destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
<property name="filters" value="config,stat"/>
<property name="connectionProperties" value="config.decrypt=true" />
</bean>
<!-- 配置SessionFactory-->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<!-- 1: 连接池(数据库连接信息) -->
<property name="dataSource" ref="dataSource" />
<!-- 2: Hibernate的属性配置 -->
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
hibernate.hbm2ddl.auto=update
hibernate.show_sql=false
</value>
</property>
<!-- 3: 关联映射文件 -->
<property name="mappingLocations" value="classpath:com/gdin/wms/domain/*.hbm.xml"/>
</bean>
<!-- 事务配置 -->
<!-- what: 事务管理器 -->
<bean id="txManager"
class="org.springframework.orm.hibernate4.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- when: 事务方法属性 -->
<tx:advice id="crudAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="get*" read-only="true"/>
<tx:method name="list*" read-only="true"/>
<tx:method name="query*" read-only="true"/>
<tx:method name="*" propagation="REQUIRED"/>
</tx:attributes>
</tx:advice>
<!-- where: 切入点 -->
<aop:config>
<aop:pointcut expression="execution(* com.gdin.wms.service.*Service.*(..))"
id="crudPoint" />
<aop:advisor advice-ref="crudAdvice" pointcut-ref="crudPoint" />
</aop:config>
</beans>
2.applicationContext-dao.xml
<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.xsd">
<!-- 基础bean元素 -->
<bean id="baseDAO" abstract="true">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
<!-- 配置dao -->
<bean id="departmentDAO" class="com.gdin.wms.dao.impl.DepartmentDAOImpl"
parent="baseDAO" />
<bean id="employeeDAO" class="com.gdin.wms.dao.impl.EmployeeDAOImpl"
parent="baseDAO" />
</beans>
3.applicationContext-Service.xml
<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.xsd">
<!-- 配置service -->
<bean id="departmentService" class="com.gdin.wms.service.impl.DepartmentServiceImpl">
<property name="dao" ref="departmentDAO"/>
</bean>
<bean id="employeeService" class="com.gdin.wms.service.impl.EmployeeServiceImpl">
<property name="dao" ref="employeeDAO"/>
</bean>
</beans>
4.application-action.xml
<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.xsd">
<!-- 配置Action -->
<bean id="departmentAction" class="com.gdin.wms.web.action.DepartmentAction"
scope="prototype">
<property name="service" ref="departmentService"/>
</bean>
<bean id="employeeAction" class="com.gdin.wms.web.action.EmployeeAction"
scope="prototype">
<property name="service" ref="employeeService"/>
<property name="departmentService" ref="departmentService" />
<property name="roleService" ref="roleService" />
</bean>
</beans>
5.struts.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD StrutsConfiguration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<!-- 控制提交日期是以文格式编码 -->
<constant name="struts.locale" value="zh_CN"></constant>
<constant name="struts.devMode" value="false" />
<!-- 界面主题 -->
<constant name="struts.ui.theme" value="simple" />
<package name="default" namespace="/"extends="struts-default">
<interceptors>
<!-- 注册拦截器 -->
<interceptor name="checkLogin"
class="com.gdin.wms.web.interceptor.CheckLoginInterceptor"/>
<interceptor name="security"
class="com.gdin.wms.web.interceptor.SecurityInterceptor"/>
<!-- 定义拦截器栈 -->
<interceptor-stack name="myStatck">
<interceptor-ref name="store">
<param name="operationMode">AUTOMATIC</param>
</interceptor-ref>
<!-- <interceptor-refname="checkLogin"/> <interceptor-refname="security"/> -->
<interceptor-ref name="paramsPrepareParamsStack" />
</interceptor-stack>
</interceptors>
<!-- 引用拦截器 -->
<default-interceptor-ref name="myStatck" />
<!-- 全局结果视图 -->
<global-results>
<result name="error">/WEB-INF/views/common/error.jsp</result>
<result name="login">/login.jsp</result>
<result name="nopermission">/WEB-INF/views/common/nopermission.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping result="error"exception="java.lang.Exception"></exception-mapping>
</global-exception-mappings>
<action name="login" class="loginAction">
<interceptor-ref name="paramsPrepareParamsStack" />
<result name="success" type="redirectAction">main</result>
</action>
<action name="main">
<result>/WEB-INF/views/main.jsp</result>
</action>
<action name="systemMenu_*" class="systemMenuAction" method="{1}">
<result name="success" type="redirectAction">
<param name="actionName">systemMenu</param>
<param name="qo.parentId">${qo.parentId}</param>
</result>
<result name="list">/WEB-INF/views/systemMenu/list.jsp
</result>
<result name="input">/WEB-INF/views/systemMenu/input.jsp</result>
</action>
<action name="*_*" class="{1}Action"method="{2}">
<result name="success" type="redirectAction">{1}</result>
<result name="list">/WEB-INF/views/{1}/list.jsp</result>
<result name="input">/WEB-INF/views/{1}/input.jsp</result>
<result name="{2}">/WEB-INF/views/{1}/{2}.jsp
</result>
</action>
</package>
</struts>
日志的打印:log4j.properties
log4j.rootLogger=ERROR,stdout,logfile
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
#\u6253\u5370\u7684\u683C\u5F0F
log4j.appender.stdout.layout.ConversionPattern=%d%p[%c]:%L-%m%n
log4j.appender.logfile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.logfile.File=D://druid.log
log4j.appender.logfile.MaxFileSize=512KB
log4j.appender.logfile.MaxBackupIndex=3
log4j.appender.logfile.Threshold=INFO
log4j.appender.logfile.layout=org.apache.log4j.PatternLayout
log4j.appender.logfile.layout.ConversionPattern=%d{ABSOLUTE}%5p%c{1}:%L-%m%n
web.xml前端的配置
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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_3_0.xsd"
version="3.0">
<!-- 告诉ContextLoaderListener,去哪里去加载Spring的主配置文件 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!-- 启动Tomcat时,创建Spring容器 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- OSIV-->
<filter>
<filter-name>OSIV</filter-name>
<filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>OSIV</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 前端控制器 -->
<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>*.action</url-pattern>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<!-- Druid监控 -->
<servlet>
<servlet-name>DruidStatView</servlet-name>
<servlet-class>com.alibaba.druid.support.http.StatViewServlet</servlet-class>
<init-param>
<!-- 允许清空统计数据 -->
<param-name>resetEnable</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<!-- 用户名 -->
<param-name>loginUsername</param-name>
<param-value>druid</param-value>
</init-param>
<init-param>
<!-- 密码 -->
<param-name>loginPassword</param-name>
<param-value>druid</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>DruidStatView</servlet-name>
<url-pattern>/druid/*</url-pattern>
</servlet-mapping>
</web-app>