File tree Expand file tree Collapse file tree
java/org/apache/struts/helloworld/action Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33import org .apache .struts .helloworld .model .MessageStore ;
44import org .apache .struts2 .ActionSupport ;
5+ import org .apache .struts2 .interceptor .parameter .StrutsParameter ;
56
67/**
78 * Acts as a Struts 2 controller that responds
@@ -33,6 +34,7 @@ public String getUserName() {
3334 return userName ;
3435 }
3536
37+ @ StrutsParameter
3638 public void setUserName (String userName ) {
3739 this .userName = userName ;
3840 }
Original file line number Diff line number Diff line change 11<?xml version =" 1.0" encoding =" UTF-8" ?>
2- <web-app id =" WebApp_ID" version =" 2.4" xmlns =" http://java.sun.com/xml/ns/j2ee" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : schemaLocation =" http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
2+ <web-app id =" WebApp_ID" version =" 6.0"
3+ xmlns =" https://jakarta.ee/xml/ns/jakartaee"
4+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
5+ xsi : schemaLocation =" https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd" >
36<display-name >Coding Actions</display-name >
47 <welcome-file-list >
58 <welcome-file >index.jsp</welcome-file >
Original file line number Diff line number Diff line change 1515
1616 <packaging >war</packaging >
1717
18+ <dependencies >
19+ <dependency >
20+ <groupId >org.apache.struts</groupId >
21+ <artifactId >struts2-config-browser-plugin</artifactId >
22+ </dependency >
23+ </dependencies >
24+
1825 <build >
1926 <finalName >exception-handling</finalName >
2027 <plugins >
Original file line number Diff line number Diff line change 22
33import org .apache .struts .helloworld .model .MessageStore ;
44import org .apache .struts2 .ActionSupport ;
5+ import org .apache .struts2 .interceptor .parameter .StrutsParameter ;
56
67/**
78 * Acts as a Struts 2 controller that responds
@@ -37,6 +38,7 @@ public String getUserName() {
3738 return userName ;
3839 }
3940
41+ @ StrutsParameter
4042 public void setUserName (String userName ) {
4143 this .userName = userName ;
4244 }
Original file line number Diff line number Diff line change 33import org .apache .struts .register .exceptions .SecurityBreachException ;
44import org .apache .struts .register .model .Person ;
55import org .apache .struts2 .ActionSupport ;
6+ import org .apache .struts2 .interceptor .parameter .StrutsParameter ;
67
78/**
89 * Acts as a controller to handle actions related to registering a user.
@@ -43,6 +44,7 @@ public void throwSecurityException() throws SecurityBreachException {
4344 "Security breach exception thrown from throwSecurityException" );
4445 }
4546
47+ @ StrutsParameter (depth = 1 )
4648 public Person getPersonBean () {
4749
4850 return personBean ;
Original file line number Diff line number Diff line change 6969 <result name =" success" >/HelloWorld.jsp</result >
7070 </action >
7171
72+ <action name =" registerForm" >
73+ <result >/register.jsp</result >
74+ </action >
75+
7276 <action name =" register" class =" org.apache.struts.register.action.Register" method =" execute" >
73- <result name =" success" >/thankyou.jsp</result >
77+ <result name =" success" >/thankyou.jsp</result >
78+ <result name =" input" >/register.jsp</result >
7479 </action >
7580
7681 </package >
Original file line number Diff line number Diff line change 11<?xml version =" 1.0" encoding =" UTF-8" ?>
2- <web-app id =" WebApp_ID" version =" 2.4" xmlns =" http://java.sun.com/xml/ns/j2ee" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : schemaLocation =" http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
3- <display-name >Exception Handling</display-name >
4- <welcome-file-list >
5- <welcome-file >index.jsp</welcome-file >
6- </welcome-file-list >
7-
8-
2+ <web-app id =" WebApp_ID" version =" 6.0"
3+ xmlns =" https://jakarta.ee/xml/ns/jakartaee"
4+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
5+ xsi : schemaLocation =" https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd" >
6+
7+ <display-name >Exception Handling</display-name >
8+ <welcome-file-list >
9+ <welcome-file >index.jsp</welcome-file >
10+ </welcome-file-list >
11+
912 <filter >
1013 <filter-name >struts2</filter-name >
1114 <filter-class >org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter</filter-class >
1518 <filter-name >struts2</filter-name >
1619 <url-pattern >/*</url-pattern >
1720 </filter-mapping >
18-
21+
1922</web-app >
Original file line number Diff line number Diff line change 1717 <h4 >Exception Details: <s:property value =" exceptionStack" /></h4 >
1818
1919
20- <p ><a href =" index.jsp " >Return to the home page.</a ></p >
20+ <p ><a href =" <s:url action=' index' /> " >Return to the home page.</a ></p >
2121</body >
2222
2323</html >
Original file line number Diff line number Diff line change 2323 <s:submit value =" Submit" />
2424 </s:form >
2525
26- <p ><a href =" register.jsp " >Please register</a > for our prize drawing.</p >
26+ <p ><a href =' <s:url action="registerForm" /> ' >Please register</a > for our prize drawing.</p >
2727 <p ><a href =' <s:url action="causeexception" />' >Cause Exception</a ></p >
2828 <p ><a href =' <s:url action="causenullpointerexception" />' >Cause Null Pointer Exception</a ></p >
2929 <p ><a href =' <s:url action="causesecurityexception" />' >Cause Global Security Exception</a ></p >
Original file line number Diff line number Diff line change 1111
1212 <p >Please login</p >
1313
14- <p ><a href =" index.jsp " >Return to the home page.</a ></p >
14+ <p ><a href =" <s:url action=' index' /> " >Return to the home page.</a ></p >
1515
1616 <hr >
1717
You can’t perform that action at this time.
0 commit comments