File tree 9 files changed +207
-10
lines changed
9 files changed +207
-10
lines changed Original file line number Diff line number Diff line change
1
+ <%@ page language =" java" contentType =" text/html; charset=UTF-8"
2
+ pageEncoding =" UTF-8" %>
3
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" >
4
+ <html >
5
+ <head >
6
+ <meta http-equiv =" Content-Type" content =" text/html; charset=UTF-8" >
7
+ <title >teacher_add_success</title >
8
+ </head >
9
+ <body >
10
+ <p >teacher_add_success!</p >
11
+ </body >
12
+ </html >
Original file line number Diff line number Diff line change
1
+ <%@ page language =" java" contentType =" text/html; charset=UTF-8"
2
+ pageEncoding =" UTF-8" %>
3
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" >
4
+ <html >
5
+ <head >
6
+ <meta http-equiv =" Content-Type" content =" text/html; charset=UTF-8" >
7
+ <title >teacher_delete_success</title >
8
+ </head >
9
+ <body >
10
+ teacher_delete_success!
11
+ </body >
12
+ </html >
Original file line number Diff line number Diff line change 15
15
<title >页面未找到</title >
16
16
</head >
17
17
<body >
18
- 路径问题path开始
18
+ < br /> 路径问题path开始
19
19
<br >
20
20
<a href =" path/path.action" >路径问题</a >
21
- <br > 路径问题path结束
21
+ <br / > 路径问题path结束
22
22
<br >
23
- <br > ActionMethod开始
23
+ <br / > ActionMethod开始
24
24
<br > Action执行的时候并不一定要执行execute方法
25
- <br / > 可以在配置文件中配置Action的时候用method=来指定执行哪个方法
25
+ <br > 可以在配置文件中配置Action的时候用method=来指定执行哪个方法
26
26
也可以在url地址中动态指定(动态方法调用DMI)(推荐)
27
- <br / >
27
+ <br >
28
28
<a href =" <%= context % > /user/userAdd" >添加用户 不推荐</a >
29
- <br / >
29
+ <br >
30
30
<a href =" <%= context % > /user/user!add" >添加用户 推荐动态DMI</a >
31
- <br / > 前者会产生太多的action,所以不推荐使用;但是使用之前把struts.xml里面一句话修改成为 constant
31
+ <br > 前者会产生太多的action,所以不推荐使用;但是使用之前把struts.xml里面一句话修改成为 constant
32
32
name="struts.enable.DynamicMethodInvocation" value="true"
33
- <br > ActionMethod结束
33
+ <br /> ActionMethod结束
34
+ <br >
35
+ <br />通配符开始 ActionWildcard
36
+ <br > 使用通配符,将配置量降到最低
37
+ <br >
38
+ <a href =" <%= context % > /actions/Studentadd" >添加学生</a >
39
+ <a href =" <%= context % > /actions/Studentdelete" >删除学生</a >
40
+ <br > 不过,一定要遵守"约定优于配置"的原则
41
+ <br >
42
+ <a href =" <%= context % > /actions/Teacher_add" >添加老师</a >
43
+ <a href =" <%= context % > /actions/Teacher_delete" >删除老师</a >
44
+ <a href =" <%= context % > /actions/Course_add" >添加课程</a >
45
+ <a href =" <%= context % > /actions/Course_delete" >删除课程</a >
46
+ <br />通配符结束ActionWildcard
34
47
<br >
35
48
36
49
<p >Loading ...</p >
Original file line number Diff line number Diff line change
1
+ <%@ page language =" java" contentType =" text/html; charset=UTF-8"
2
+ pageEncoding =" UTF-8" %>
3
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" >
4
+ <html >
5
+ <head >
6
+ <meta http-equiv =" Content-Type" content =" text/html; charset=UTF-8" >
7
+ <title >studentadd_success</title >
8
+ </head >
9
+ <body >
10
+ studentadd_success!
11
+ </body >
12
+ </html >
Original file line number Diff line number Diff line change
1
+ <%@ page language =" java" contentType =" text/html; charset=UTF-8"
2
+ pageEncoding =" UTF-8" %>
3
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd" >
4
+ <html >
5
+ <head >
6
+ <meta http-equiv =" Content-Type" content =" text/html; charset=UTF-8" >
7
+ <title >studentdelete_success</title >
8
+ </head >
9
+ <body >
10
+ studentdelete_success!
11
+ </body >
12
+ </html >
Original file line number Diff line number Diff line change 29
29
</action >
30
30
</package >
31
31
32
- <!-- namespace -->
32
+ <!-- namespace开始 -->
33
33
<package name =" front" extends =" struts-default" namespace =" /front" >
34
34
<action name =" namespace" >
35
35
<result >
46
46
</result >
47
47
</action >
48
48
</package >
49
+ <!-- namespace结束 -->
49
50
50
51
<!-- action开始 -->
51
52
<package name =" action" extends =" struts-default" namespace =" /" >
89
90
</package >
90
91
<!-- ActionMethod结束 -->
91
92
93
+ <!-- 通配符开始 ActionWildcard -->
94
+ <package name =" actions" extends =" struts-default" namespace =" /actions" >
95
+ <action name =" Student*" class =" com.struts2.front.action.StudentAction"
96
+ method=" {1}" >
97
+ <result >
98
+ /student{1}_success.jsp
99
+ </result >
100
+ </action >
101
+ <action name =" *_*" class =" com.struts2.front.action.{1}Action" >
102
+ <result >
103
+ /{1}_{2}_success.jsp
104
+ </result >
105
+ </action >
106
+ </package >
107
+ <!-- 通配符结束 ActionWildcard -->
92
108
93
109
</struts >
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
Original file line number Diff line number Diff line change
1
+ /*************************************************************************************************
2
+ * 版权所有 (C)2015
3
+ *
4
+ * 文件名称:StudentAction.java
5
+ * 内容摘要:StudentAction.java
6
+ * 当前版本:TODO
7
+ * 作 者:李加蒙
8
+ * 完成日期:2016年8月16日 下午3:55:26
9
+ * 修改记录:
10
+ * 修改日期:2016年8月16日 下午3:55:26
11
+ * 版 本 号:
12
+ * 修 改 人:
13
+ * 修改内容:
14
+ ************************************************************************************************/
15
+ package com .struts2 .front .action ;
16
+
17
+ import com .opensymphony .xwork2 .ActionSupport ;
18
+
19
+ /**
20
+ * @filename 文件名称:StudentAction.java
21
+ * @contents 内容摘要:
22
+ */
23
+ public class StudentAction extends ActionSupport {
24
+ public String add () {
25
+ System .out .println ("sadd" );
26
+ return SUCCESS ;
27
+ }
28
+
29
+ public String delete () {
30
+ System .out .println ("sdelete" );
31
+ return SUCCESS ;
32
+ }
33
+ }
Original file line number Diff line number Diff line change
1
+ /*************************************************************************************************
2
+ * 版权所有 (C)2015
3
+ *
4
+ * 文件名称:TeacherAction.java
5
+ * 内容摘要:TeacherAction.java
6
+ * 当前版本:TODO
7
+ * 作 者:李加蒙
8
+ * 完成日期:2016年8月16日 下午3:55:42
9
+ * 修改记录:
10
+ * 修改日期:2016年8月16日 下午3:55:42
11
+ * 版 本 号:
12
+ * 修 改 人:
13
+ * 修改内容:
14
+ ************************************************************************************************/
15
+ package com .struts2 .front .action ;
16
+
17
+ import com .opensymphony .xwork2 .ActionSupport ;
18
+
19
+ /**
20
+ * @filename 文件名称:TeacherAction.java
21
+ * @contents 内容摘要:
22
+ */
23
+ public class TeacherAction extends ActionSupport {
24
+ public String add () {
25
+ System .out .println ("tadd" );
26
+ return SUCCESS ;
27
+ }
28
+
29
+ public String delete () {
30
+ System .out .println ("tdelete" );
31
+ return SUCCESS ;
32
+ }
33
+ }
Original file line number Diff line number Diff line change 29
29
</action >
30
30
</package >
31
31
32
- <!-- namespace -->
32
+ <!-- namespace开始 -->
33
33
<package name =" front" extends =" struts-default" namespace =" /front" >
34
34
<action name =" namespace" >
35
35
<result >
46
46
</result >
47
47
</action >
48
48
</package >
49
+ <!-- namespace结束 -->
49
50
50
51
<!-- action开始 -->
51
52
<package name =" action" extends =" struts-default" namespace =" /" >
89
90
</package >
90
91
<!-- ActionMethod结束 -->
91
92
93
+ <!-- 通配符开始 ActionWildcard -->
94
+ <package name =" actions" extends =" struts-default" namespace =" /actions" >
95
+ <action name =" Student*" class =" com.struts2.front.action.StudentAction"
96
+ method=" {1}" >
97
+ <result >
98
+ /student{1}_success.jsp
99
+ </result >
100
+ </action >
101
+ <action name =" *_*" class =" com.struts2.front.action.{1}Action" >
102
+ <result >
103
+ /{1}_{2}_success.jsp
104
+ </result >
105
+ </action >
106
+ </package >
107
+ <!-- 通配符结束 ActionWildcard -->
92
108
93
109
</struts >
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+
127
+
128
+
You can’t perform that action at this time.
0 commit comments