File tree Expand file tree Collapse file tree
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
@@ -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 22
33import org .apache .struts .register .model .Person ;
44import org .apache .struts2 .ActionSupport ;
5+ import org .apache .struts2 .interceptor .parameter .StrutsParameter ;
56
6- import java .util .ArrayList ;
77import java .util .List ;
88
99public class Register extends ActionSupport {
@@ -17,15 +17,10 @@ public String execute2() throws Exception {
1717 }
1818
1919 public String input () throws Exception {
20- this .options = new ArrayList <>();
21- this .options .add (3 );
2220 return INPUT ;
2321 }
2422
25- public String cancel2 () throws Exception {
26- return SUCCESS ;
27- }
28-
23+ @ StrutsParameter (depth = 1 )
2924 public Person getPersonBean () {
3025 return personBean ;
3126 }
@@ -34,6 +29,7 @@ public void setPersonBean(Person person) {
3429 personBean = person ;
3530 }
3631
32+ @ StrutsParameter (depth = 1 )
3733 public List <Integer > getOptions () {
3834 return options ;
3935 }
Original file line number Diff line number Diff line change 66 <constant name =" struts.devMode" value =" true" />
77 <constant name =" struts.enable.DynamicMethodInvocation" value =" true" />
88 <constant name =" struts.mapper.action.prefix.enabled" value =" true" />
9+ <constant name =" struts.allowlist.classes" value =" org.apache.struts.helloworld.model.MessageStore" />
910
1011 <package name =" basicstruts" namespace =" /" extends =" struts-default" >
1112 <default-action-ref name =" index" />
3334 <action name =" register" class =" org.apache.struts.register.action.Register" method =" input" >
3435 <result name =" input" >/WEB-INF/register.jsp</result >
3536 </action >
36- <action name =" register-cancel" class = " org.apache.struts.register.action.Register " method = " cancel2 " >
37+ <action name =" register-cancel" >
3738 <result type =" redirectAction" >index</result >
3839 </action >
3940 <action name =" register-submit" class =" org.apache.struts.register.action.Register" method =" execute2" >
Original file line number Diff line number Diff line change 2020 <s:submit value =" Submit" />
2121 </s:form >
2222
23- <p ><a href =" register" >Please register</a > for our prize drawing.</p >
23+ <p ><a href =" <s:url action=' register'/> " >Please register</a > for our prize drawing.</p >
2424 </body >
2525</html >
Original file line number Diff line number Diff line change 99<body >
1010<h3 >Register for a prize by completing this form.</h3 >
1111
12- <s:form action =" register-submit" namespace =" test" >
12+ <s:form action =" register-submit" namespace =" / test" >
1313 <s:textfield name =" personBean.firstName" label =" First name" />
1414 <s:textfield name =" personBean.lastName" label =" Last name" />
1515 <s:textfield name =" personBean.email" label =" Email" />
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"
3- xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
4- 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" >
56 <display-name >Form_Processing_Struts2_Mvn</display-name >
67
78 <filter >
You can’t perform that action at this time.
0 commit comments