1.项目视图如下图所示。
struts的配置文件为struts.xml,spring的配置文件为WEB-INF/applicationContext.xml,JPA的配置文件为META-INFA/persistense.xml
2.struts的配置文件struts.xml
encoding="UTF-8"?>
/p>
"-//Apache Software Foundation//DTD Struts
Configuration 2.1//EN"
"http://struts.apache.org/dtds/struts-2.1.dtd">
name="struts.custom.i18n.resources"
value="messageResource"/>
name="struts.i18n.encoding" value="UTF-8"/>
file="struts_common.xml">
file="struts_mealunit.xml">
file="struts_regulator.xml">
file="struts_sysmgr.xml">
file="struts_sysset.xml">
extends="struts-default">
name="authority"
class="net.kerun.suozheng.interceptor.AuthorityInterceptor"/>
name="suoZhengStack">
name="defaultStack"/>
name="authority"/>
name="login"
type="redirect">../index.jsp
name="exception">common/error.jsp
exception="net.kerun.suozheng.exception.SuoZhengException"
result="exception"/>
exception="java.lang.Exception"
result="exception"/>
name="login" class="net.kerun.suozheng.action.UserAction"
method="login">
name="default">common/index.jsp
name="input">login.jsp
name="defaultStack"/>
name="loginBefore" class="net.kerun.suozheng.action.UserAction"
method="loginBefore">
name="login">common/login.jsp
name="defaultStack"/>
3.spring的配置文件applicationContext.xml
id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean"
destroy-method="destroy">
name="persistenceUnitName"
value="sz">
transaction-manager="transactionManager" />
id="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
name="entityManagerFactory" ref="entityManagerFactory"
/>
4.JPA的配置文件persistense.xml
encoding="UTF-8"?>
version="2.0"
xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
name="suozhengSS2H"
transaction-type="RESOURCE_LOCAL">
org.hibernate.ejb.HibernatePersistence
net.kerun.suozheng.entity.BatchTab
...还有其它的实体类...
name="hibernate.connection.driver_class"
value="net.sourceforge.jtds.jdbc.Driver"/>
name="hibernate.connection.url"
value="jdbc:jtds:sqlserver://127.0.0.1:1433;DatabaseName=sz;SelectMethod=cursor"/>
name="hibernate.connection.username"
value="sz"/>
name="hibernate.connection.password"
value="sz"/>
name="hibernate.hbm2ddl.auto" value="update"
/>
name="hibernate.show_sql" value="true" />
name="hibernate.format_sql" value="true" />
name="hibernate.dialect"
value="org.hibernate.dialect.SQLServerDialect"
/>
name="hibernate.cache.provider_class"
value="org.hibernate.cache.HashtableCacheProvider"
/>
5.web.xml
encoding="UTF-8"?>
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">
sz
contextConfigLocation
/WEB-INF/applicationContext.xml
org.springframework.web.context.ContextLoaderListener
struts-cleanup
org.apache.struts2.dispatcher.ActionContextCleanUp
struts-cleanup
/*
struts2
org.apache.struts2.dispatcher.FilterDispatcher
struts2
/*
encodingFilter
org.springframework.web.filter.CharacterEncodingFilter
encodingFilter
UTF-8
encodingFilter
/*
AuthImg
net.kerun.suozheng.servlet.AuthImg
AuthImg
/AuthImg.jpg
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp