博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
maven整合S2SH
阅读量:6037 次
发布时间:2019-06-20

本文共 18433 字,大约阅读时间需要 61 分钟。

1.pom.xml

1 
2
4
4.0.0
5
6
JavaPrj_2
7
com.goshop
8
0.0.1-SNAPSHOT
9
10
com.goshop
11
JavaPrj_2-web
12
0.0.1-SNAPSHOT
13
war
14
JavaPrj_2-web Maven Webapp
15
http://maven.apache.org
16
17
18
junit
19
junit
20
3.8.1
21
test
22
23 24
25
com.goshop
26
JavaPrj_2-service
27
0.0.1-SNAPSHOT
28
29
30
org.apache.struts
31
struts2-jfreechart-plugin
32
2.0.6
33
34
35
jfree
36
jcommon
37
1.0.16
38
39
40
jfree
41
jfreechart
42
1.0.9
43
44
45
46
org.springframework
47
spring-core
48
3.1.2.RELEASE
49
50
51
org.springframework
52
spring-context
53
3.1.2.RELEASE
54
55
56
org.springframework
57
spring-jdbc
58
3.1.2.RELEASE
59
60
61
org.springframework
62
spring-beans
63
3.1.2.RELEASE
64
65
66
org.springframework
67
spring-web
68
3.1.2.RELEASE
69
70
71
org.springframework
72
spring-expression
73
3.1.2.RELEASE
74
75
76
org.springframework
77
spring-orm
78
3.1.2.RELEASE
79
80 81
82
83
org.apache.struts
84
struts2-core
85
2.3.16
86
96
97
98
99
org.apache.struts
100
struts2-convention-plugin
101
2.3.20
102
103
104
105
org.apache.struts
106
struts2-config-browser-plugin
107
2.3.20
108
109
110
111
org.apache.struts
112
struts2-spring-plugin
113
2.3.4.1
114
115 116
117
118
org.hibernate
119
hibernate-core
120
4.1.7.Final
121
122 123
124
125
mysql
126
mysql-connector-java
127
5.1.34
128
129 130
131
132
com.alibaba
133
druid
134
1.0.12
135
136 137
138
139
org.aspectj
140
aspectjweaver
141
1.8.5
142
143
144
c3p0
145
c3p0
146
0.9.1.2
147
148 149
150
org.hibernate
151
hibernate-core
152
3.6.10.Final
153
154 155
156
log4j
157
log4j
158
1.2.17
159
160
161
162
JavaPrj_2-web
163
164

 

 

2.web.xml

1 
2
6 7
8
9
org.springframework.web.context.ContextLoaderListener
10
11
12
13
contextConfigLocation
14
classpath*:applicationContext.xml
15
16
17
log4jConfigLocation
18
classpath:Log4j.properties
19
20
21
org.springframework.web.util.Log4jConfigListener
22
23
24
struts2
25
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
26
27 28
29
struts2
30
/*
31
32

 

3.applicationContext.xml

1 
2
3
16 17
18
19
20
21
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
43
44
45
46
47
48
49
com/goshop/domain/Person.hbm.xml
50
com/goshop/domain/Vote.hbm.xml
51
com/goshop/domain/VoteOption.hbm.xml
52
53
54
55
56
57
58 hibernate.dialect=org.hibernate.dialect.MySQLInnoDBDialect 59 hibernate.hbm2ddl.auto=update 60 hibernate.show_sql=true 61 hibernate.format_sql=true; 62
63
64
65
66
68
69
70
71 72
74
75
76
77 78
80
81
82
83 84
85
87
88
89
90 91 92
93
94
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
113
114
116
117 118

 

5.struts.xml

1 
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

 

6.

1 
2 3
4
5
6
/index.jsp
7
/index.jsp
8
9
10

 

7.

1 
2 3
4
5
6
7
400 8
300 9
10
11
12

 

8.

1 
2 3
4
5
6
/index.jsp
7
8
9

 

9.

1 
2 3
4
5
6
/list.jsp
7
8
9
11
12
/error.jsp
13
/welcome.jsp
14
15
16
17
/{1}.jsp
18
19
20

 

8.log4j.properties

1 \u4E0B\u9762\u5B9A\u4E49\u65E5\u5FD7\u8F93\u51FA\u7EA7\u522B\u662F INFO\uFF0C\u5E76\u4E14\u914D\u7F6E\u4E862\u4E2A\u8F93\u51FA\u76EE\u7684\u5730\uFF0C\u4E00\u4E2A\u662FA3\uFF0C\u4E00\u4E2A\u662Fconsole 2  3 log4j.rootLogger = INFO,A3,CONSOLE 4  5 //\u65E5\u5FD7\u6700\u4F4E\u7684\u8F93\u51FA\u7EA7\u522B 6 log4j.appender.A3.Threshold=INFO 7 log4j.appender.A3.encoding=UTF-8 8 //\u6BCF\u5929\u4EA7\u751F\u4E00\u4E2A\u6587\u4EF6DailyRollingFileAppender   9 log4j.appender.A3 = org.apache.log4j.DailyRollingFileAppender10 //file \u5C5E\u6027  \u6307\u5B9A\u4EA7\u751F\u65E5\u5FD7\u6587\u4EF6\u7684\u4FDD\u5B58\u4F4D\u7F6E\u53CA\u6587\u4EF6\u540D\uFF0C\u8FD9\u91CC\u662Fwindows\u4E0B\u7684\u914D\u7F6E11 // c:/logtest/logtest.log\uFF0C12 //\u516C\u53F8\u9879\u76EE\u5728linux\u4E0B\u7684\u914D\u7F6E\u662F/app/weblogic/applications/logs/sxvip_logs13 log4j.appender.A3.File=e:/logtest/logtest.log14 //\u5F53\u6709\u65E5\u5FD7\u65F6\u7ACB\u5373\u8F93\u51FA\uFF0C\u9ED8\u8BA4\u662Ftrue15 log4j.appender.A3.ImmediateFlush=true16 log4j.appender.A3.DatePattern='_'yyyy-MM-dd17 //\u65E5\u5FD7\u5E03\u5C40\u65B9\u5F0F18 log4j.appender.A3.layout=org.apache.log4j.PatternLayout19 //\u65E5\u5FD7\u6587\u4EF6\u4E2D\u65E5\u5FD7\u7684\u683C\u5F0F20 log4j.appender.A3.layout.ConversionPattern=%-d{yyyy/MM/dd HH:mm:ss} OSS %-5p [%c] - %m%n21 22 //\u8FD9\u91CC\u4F7F\u7528org.apache.log4j.ConsoleAppender\u6307\u5B9A\u8981\u628A\u65E5\u5FD7\u8F93\u51FA\u5230\u63A7\u5236\u53F023 log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender24 log4j.appender.Threshold=INFO25 //\u8F93\u51FA\u76EE\u6807\u662F \u63A7\u5236\u53F026 log4j.appender.CONSOLE.Target=System.out27 log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout28 log4j.appender.CONSOLE.layout.ConversionPattern=%-d{yyyy/MM/dd HH:mm:ss} OSS %-5p [%c] - %m%n

 

9.testAction

1 package com.goshop.action; 2  3 import org.apache.struts2.convention.annotation.Action; 4 import org.apache.struts2.convention.annotation.Namespace; 5 import org.apache.struts2.convention.annotation.ParentPackage; 6 import org.springframework.beans.factory.annotation.Autowired; 7 import org.springframework.context.annotation.Scope; 8 import org.springframework.stereotype.Controller; 9 10 import com.goshop.service.IUserService;11 import com.opensymphony.xwork2.ActionSupport;12 @Controller  13 @Scope("prototype")14 public class TestAction extends ActionSupport {15 16     17     public String test(){18         19         return "success";20     }21     22 }

 

 

10.RegisterAction

1 package com.goshop.action; 2  3 import org.apache.commons.logging.Log; 4 import org.apache.commons.logging.LogFactory; 5  6 import com.goshop.domain.Person; 7 import com.goshop.service.Service; 8 import com.opensymphony.xwork2.ActionSupport; 9 10 public class RegistAction  extends ActionSupport{11 12       //下面是用于封装用户请求参数的属性  13     private Person person;  14     //用于封装处理结果的属性  15     private String tip;  16     //系统所用的业务逻辑组件  17     private Service service;  18     //设置注入业务逻辑组件所必需的setter方法  19     public void setService(Service service)  20     {  21         this.service = service;  22     }  23   24     //person属性的setter和getter方法  25     public void setPerson(Person person)  26     {  27         this.person = person;  28     }  29     public Person getPerson()  30     {  31         return this.person;  32     }  33   34     //tip属性的setter和getter方法  35     public void setTip(String tip)  36     {  37         this.tip = tip;  38     }  39     public String getTip()  40     {  41         return this.tip;  42     }  43   44     private static final Log log = LogFactory.getLog(RegistAction.class);45     46     47     //处理用户请求的execute方法  48     public String execute()  49         throws Exception  50     {  51         log.info("注册校验开始.........................");52         //调用业务逻辑组件的regist方法来处理请求  53         if (service.regist(person))  54         {  55             setTip("哈哈,注册成功!");  56             log.info("注册成功");57             return SUCCESS;  58         }  59         else  60         {  61             log.error("注册失败");62             return ERROR;  63         }  64     }  65 }

 

11, service

1 package com.goshop.service; 2 /** 3  * 测试用 4  * @author ThinkPad 5  * 6  */ 7 public interface IUserService { 8  9     public void test();10 }

 

12.service.impl

1 package com.goshop.service.impl; 2  3 import org.springframework.stereotype.Service; 4  5 import com.goshop.service.IUserService; 6  7 @Service("userService") 8 public class UserServiceImpl implements IUserService{ 9 10     public void test() {11         System.out.println("hello..world");12     }13 14 }

 

13.service

1 package com.goshop.service;2 3 import com.goshop.domain.Person;4 5 public interface Service {6     7     //注册用户  8     boolean regist(Person person);  9 }

 

14.service.impl

1 package com.goshop.service.impl; 2  3 import com.goshop.dao.PersonDao; 4 import com.goshop.domain.Person; 5 import com.goshop.service.Service; 6  7 public class ServiceImpl implements Service{ 8  9      private PersonDao personDao;  10     11     12     public PersonDao getPersonDao() {13         return personDao;14     }15 16 17     public void setPersonDao(PersonDao personDao) {18         this.personDao = personDao;19     }20 21 22     public boolean regist(Person person) {23         int result = personDao.save(person);24         if(result>0){25             return true;26         }27         return false;28     }29 30 }

 

15.dao

1 package com.goshop.dao; 2  3 import java.util.List; 4  5 import com.goshop.domain.Person; 6  7 public interface PersonDao { 8       /**  9      * 加载Person实例 10      * @param id 需要加载的Person实例的主键值 11      * @return 返回加载的Person实例 12      */   13     Person get(Integer id);  14        15     /** 16      * 保存Person实例 17      * @param person 需要保存的Person实例 18      * @return 刚刚保存的Person实例的标识属性值 19      */   20     Integer save(Person person);  21       22     /** 23      * 修改Person实例 24      * @param person 需要修改的Person实例 25      */  26     void update(Person person);  27       28     /** 29      * 删除Person实例 30      * @param id 需要删除的Person实例的标识属性值 31      */  32     void delete(Integer id);  33       34     /** 35      * 删除Person实例 36      * @param person 需要删除的Person实例 37      */  38     void delete(Person person);  39       40     /** 41      * 根据用户名查找Person 42      * @param name 查询的人名 43      * @return 指定用户名对应的全部Person 44      */  45     List
findByName(String name); 46 47 /** 48 * 查询全部Person实例 49 * @return 全部Person实例 50 */ 51 public List
findAllPerson(); 52 }

 

16.dao.impl

1 package com.goshop.dao.impl; 2  3 import java.util.List; 4  5 import org.springframework.orm.hibernate3.support.HibernateDaoSupport; 6  7 import com.goshop.dao.PersonDao; 8 import com.goshop.domain.Person; 9 10 public class PersonDaoHibernate extends HibernateDaoSupport implements PersonDao{11 12     public Person get(Integer id) {13         return this.getHibernateTemplate().get(Person.class, id);14     }15 16     public Integer save(Person person) {17         return (Integer) this.getHibernateTemplate().save(person);18     }19 20     public void update(Person person) {21         this.getHibernateTemplate().update(person);22     }23 24     public void delete(Integer id) {25         this.getHibernateTemplate().delete(get(id));26     }27 28     public void delete(Person person) {29         this.getHibernateTemplate().delete(person);30     }31 32     public List
findByName(String name) {33 return (List
)this.getHibernateTemplate().find("from Person p where p.name like ?",name);34 }35 36 public List
findAllPerson() {37 return (List
)this.getHibernateTemplate().find("from Person");38 }39 40 }

 

 

1 
2 5
6
7
8
9
10
11
12
13

 

 

1 package com.goshop.domain; 2  3 public class Person { 4     private Integer id; 5     private String name; 6     private int age; 7     public Integer getId() { 8         return id; 9     }10     public void setId(Integer id) {11         this.id = id;12     }13     public String getName() {14         return name;15     }16     public void setName(String name) {17         this.name = name;18     }19     public int getAge() {20         return age;21     }22     public void setAge(int age) {23         this.age = age;24     }25 26     27 }

 

转载于:https://www.cnblogs.com/sharpest/p/6037252.html

你可能感兴趣的文章
我的友情链接
查看>>
Outlook 2013 重新联姻Hotmail ,Exchange ActiveSync牵线搭桥
查看>>
Perl哈希的用法总结
查看>>
浪潮从行业云到行业云服务
查看>>
clickhouse部署(centos6.9和ubuntu 14.04)
查看>>
利用HAProxy取代nginx代理activemq
查看>>
Linux磁盘管理高级
查看>>
什么是架构!!!!
查看>>
JDBC及相关【转】
查看>>
对象排序 — java 7 collection详解(三)
查看>>
2016年3月9日作业
查看>>
linux Postfix 服务器配置及应用上
查看>>
Easily export trained Apache Spark ML models and pipelines
查看>>
CPU负载排查
查看>>
PAM禁止root用户登录,限制普通su切换
查看>>
我的友情链接
查看>>
TestNG中如何执行测试-直接执行&批量执行
查看>>
代码审计工具
查看>>
进程的相关管理
查看>>
MFC界面库BCGControlBar v25.2新版亮点:支持Visual Studio 2017 RC
查看>>