s2sh登錄整合(一)配置文件
配置文件:1.web.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<web-app version="2.5"
3
xmlns="http://java.sun.com/xml/ns/javaee"
4
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
6
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
7
<!-- 配置spring的監(jiān)聽器 -->
8
<listener>
9
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
10
</listener>
11
<context-param>
12
<param-name>contextConfigLocation</param-name>
13
<param-value>classpath*:applicationContext-*.xml</param-value>
14
</context-param>
15
16
<!-- hibernate過濾器 -->
17
<filter>
18
<filter-name>hibernateFilter</filter-name>
19
<filter-class>
20
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
21
</filter>
22
23
<filter-mapping>
24
<filter-name>hibernateFilter</filter-name>
25
<url-pattern>*.action</url-pattern>
26
</filter-mapping>
27
28
<!-- struts2過濾器 -->
29
<filter>
30
<filter-name>struts2</filter-name>
31
<filter-class>
32
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
33
</filter-class>
34
</filter>
35
<filter-mapping>
36
<filter-name>struts2</filter-name>
37
<url-pattern>/*</url-pattern>
38
</filter-mapping>
39
40
<!-- 編碼過濾器 -->
41
<filter>
42
<filter-name>encodingFilter</filter-name>
43
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
44
<init-param>
45
<param-name>encoding</param-name>
46
<param-value>utf-8</param-value>
47
</init-param>
48
</filter>
49
<filter-mapping>
50
<filter-name>encodingFilter</filter-name>
51
<url-pattern>/*</url-pattern>
52
</filter-mapping>
53
54
<welcome-file-list>
55
<welcome-file>index.jsp</welcome-file>
56
</welcome-file-list>
57
</web-app>
58

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

2.hibernate.cfg.xml
1
<?xml version='1.0' encoding='UTF-8'?>
2
<!DOCTYPE hibernate-configuration PUBLIC
3
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
4
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
5
<!-- Generated by MyEclipse Hibernate Tools. -->
6
<hibernate-configuration>
7
<session-factory>
8
<property name="connection.username">sa</property>
9
<property name="connection.url">jdbc:sqlserver://localhost:1433;databaseName=demo</property>
10
<property name="dialect">
11
org.hibernate.dialect.SQLServerDialect
12
</property>
13
<property name="myeclipse.connection.profile">s2shcon2</property>
14
<property name="connection.password">sa</property>
15
<property name="connection.driver_class">com.microsoft.sqlserver.jdbc.SQLServerDriver</property>
16
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
17
<property name="show_sql">true</property>
18
<mapping resource="com/test/entity/Users.hbm.xml" />
19
</session-factory>
20
</hibernate-configuration>

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

3.applicationContext-*.xml
(1)applicationContext-common.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2
<beans xmlns="http://www.springframework.org/schema/beans"
3
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
xmlns:p="http://www.springframework.org/schema/p"
5
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
6
<!-- 配置SessionFactory -->
7
<bean id="sessionFactory"
8
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
9
<property name="configLocation"
10
value="classpath:hibernate.cfg.xml">
11
</property>
12
</bean>
13
<!-- 配置事務(wù)管理器 -->
14
15
<bean id="transactionManager"
16
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
17
<property name="sessionFactory" ref="sessionFactory" />
18
</bean>
19
20
<!-- 配置事務(wù)管理 -->
21
<bean id="transactionBase"
22
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
23
lazy-init="true" abstract="true">
24
<!-- 配置事務(wù)管理器 -->
25
<property name="transactionManager" ref="transactionManager" />
26
<!-- 配置事務(wù)屬性 -->
27
<property name="transactionAttributes">
28
<props>
29
<prop key="*">PROPAGATION_REQUIRED</prop>
30
</props>
31
</property>
32
</bean>
33
</beans>

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

(2)applicationContext-bean.xml


















(3)applicationContext-service.xml











(4)applicationContext-actions.xml











(5)struts.xml










