记各种抓狂,各种报错
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>usermanage</display-name>
<!--
指定SPRING的配置文件,默認從WEB根目錄尋找配置文件, 我們可以通過SPRING提供的classpath:前綴指定從該路徑下尋找
-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:/beans.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>encoding</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- struts2过滤器 -->
<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.jsp</welcome-file>
</welcome-file-list>
</web-app>
struts.xml
<?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>
<!--
使用Convention插件,实现约定大于配置的零配置文件风格. 特殊的Result路径在Action类中使用@Result设定.
-->
<!-- 設置STRUTS標籤主題為簡單,避免產生不必要的HTML代碼 -->
<constant name="struts.ui.theme" value="simple"></constant>
<!-- 設置由SPRING提供的對象工廠類接替STRUTS2的對象工廠類的工作,用於創建ACTION -->
<constant name="struts.objectFactory" value="spring"/>
<!-- struts.devMode属性,配置启用调试,将有更多的错误信息输出,便于排错 -->
<constant name="struts.devMode" value="false" />
<!-- 设置默认的父包,default包继承自struts-default -->
<constant name="struts.convention.default.parent.package"
value="struts-default" />
<!-- 搜索此配置下的所有包 -->
<constant name="struts.convention.package.locators.basePackage" value="com.travelsky.ism" />
<!-- 只要是结尾为action的包都要搜索 -->
<constant name="struts.convention.package.locators" value="action" />
<!-- convention默认会到/WEB-INF/content文件夹下面查找对应的结果页面 -->
<constant name="struts.convention.result.path" value="/WEB-INF/pages" />
<constant name="struts.ognl.allowStaticMethodAccess" value="true" />
<constant name="struts.convention.action.name.separator"
value="_" />
</struts>
beans.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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
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
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<!-- 开启注解配置,使Spring关注Annotation -->
<context:annotation-config />
<!-- 啟動掃描註解方式,掃描包下所有的文件以及子包中的文件 -->
<context:component-scan base-package="com.travelsky.ism"></context:component-scan>
<bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.SimpleNativeJdbcExtractor">
</bean>
<bean id="oracleLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler">
<property name="nativeJdbcExtractor"><ref local="nativeJdbcExtractor"/></property>
</bean>
<!-- JPA begin -->
<!-- 类工厂由spring管理 -->
<bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
<property name="persistenceUnitName" value="jpaname"/>
</bean>
<!-- 事务由spring管理 -->
<bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"/>
</bean>
<tx:annotation-driven transaction-manager="txManager"/>
</beans>
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence 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_1_0.xsd"
version="1.0">
<!-- 持久化单元,transaction-type事务类型包括全局事务类型JTA和本地事务类型 RESOURCE_LOCAL-->
<persistence-unit name="jpaname" transaction-type="RESOURCE_LOCAL">
<properties>
<!-- 数据库方言 -->
<property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
<!--
建表方式,value值为creat-drop时表示创建应用的时候建表,结束应用的时候表自动删除;
值为update表示如果映射元数据不存在则建立表,如果映射元数据存在并新增加了字段则会添加到数据库表中
-->
<property name="hibernate.hbm2ddl.auto" value="update" />
<property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver" />
<property name="hibernate.connection.username" value="sysman" />
<property name="hibernate.connection.password" value="sa" />
<property name="hibernate.connection.url" value="jdbc:oracle:thin:@127.0.0.1:1521:orcl" />
</properties>
</persistence-unit>
</persistence>