Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.apache.struts.edit.service.EditServiceInMemory;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.Preparable;
import org.apache.struts2.interceptor.parameter.StrutsParameter;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -61,6 +62,7 @@ public String input() throws Exception {
return INPUT;
}

@StrutsParameter(depth = 1)
public Person getPersonBean() {
return personBean;
}
Expand Down
4 changes: 2 additions & 2 deletions exclude-parameters/src/main/resources/struts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<struts>

<constant name="struts.devMode" value="true" />

<constant name="struts.allowlist.packageNames" value="org.apache.struts.edit.model" />
<package name="basicstruts2" extends="struts-default" >

<interceptors>
Expand All @@ -20,7 +20,7 @@
</interceptors>

<default-interceptor-ref name="appDefault" />

<default-action-ref name="index" />
<!-- If no class attribute is specified the framework will assume success and
render the result index.jsp -->
<!-- If no name value for the result node is specified the success value is the default -->
Expand Down
5 changes: 4 additions & 1 deletion exclude-parameters/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<web-app id="WebApp_ID" version="6.0"
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd">
<display-name>Exclude Parameters</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.struts.helloworld.model.MessageStore;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;

/**
* Acts as a Struts 2 controller that responds
Expand Down Expand Up @@ -37,6 +38,7 @@ public String getUserName() {
return userName;
}

@StrutsParameter
public void setUserName(String userName) {
this.userName = userName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import org.apache.struts.register.model.Person;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;

import java.util.ArrayList;
import java.util.List;

public class Register extends ActionSupport {
Expand All @@ -17,15 +17,10 @@ public String execute2() throws Exception {
}

public String input() throws Exception {
this.options = new ArrayList<>();
this.options.add(3);
return INPUT;
}

public String cancel2() throws Exception {
return SUCCESS;
}

@StrutsParameter(depth = 1)
public Person getPersonBean() {
return personBean;
}
Expand All @@ -34,6 +29,7 @@ public void setPersonBean(Person person) {
personBean = person;
}

@StrutsParameter(depth = 1)
public List<Integer> getOptions() {
return options;
}
Expand Down
3 changes: 2 additions & 1 deletion form-processing/src/main/resources/struts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<constant name="struts.devMode" value="true" />
<constant name="struts.enable.DynamicMethodInvocation" value="true"/>
<constant name="struts.mapper.action.prefix.enabled" value="true"/>
<constant name="struts.allowlist.classes" value="org.apache.struts.helloworld.model.MessageStore"/>

<package name="basicstruts" namespace="/" extends="struts-default">
<default-action-ref name="index"/>
Expand Down Expand Up @@ -33,7 +34,7 @@
<action name="register" class="org.apache.struts.register.action.Register" method="input">
<result name="input">/WEB-INF/register.jsp</result>
</action>
<action name="register-cancel" class="org.apache.struts.register.action.Register" method="cancel2">
<action name="register-cancel">
<result type="redirectAction">index</result>
</action>
<action name="register-submit" class="org.apache.struts.register.action.Register" method="execute2">
Expand Down
2 changes: 1 addition & 1 deletion form-processing/src/main/webapp/WEB-INF/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
<s:submit value="Submit" />
</s:form>

<p><a href="register">Please register</a> for our prize drawing.</p>
<p><a href="<s:url action='register'/>">Please register</a> for our prize drawing.</p>
</body>
</html>
2 changes: 1 addition & 1 deletion form-processing/src/main/webapp/WEB-INF/register.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<body>
<h3>Register for a prize by completing this form.</h3>

<s:form action="register-submit" namespace="test">
<s:form action="register-submit" namespace="/test">
<s:textfield name="personBean.firstName" label="First name"/>
<s:textfield name="personBean.lastName" label="Last name"/>
<s:textfield name="personBean.email" label="Email"/>
Expand Down
7 changes: 4 additions & 3 deletions form-processing/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<web-app id="WebApp_ID" version="6.0"
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd">
<display-name>Form_Processing_Struts2_Mvn</display-name>

<filter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.apache.struts.edit.service.EditService;
import org.apache.struts.edit.service.EditServiceInMemory;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -36,6 +37,7 @@ public String input() throws Exception {
return INPUT;
}

@StrutsParameter(depth = 1)
public Person getPersonBean() {
return personBean;
}
Expand Down
9 changes: 4 additions & 5 deletions form-tags/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<web-app id="WebApp_ID" version="6.0"
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd">

<display-name>Form Tags</display-name>
<welcome-file-list>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.struts.helloworld.model.MessageStore;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;

/**
* Acts as a Struts 2 controller that responds
Expand Down Expand Up @@ -37,6 +38,7 @@ public String getUserName() {
return userName;
}

@StrutsParameter
public void setUserName(String userName) {
this.userName = userName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.struts.register.model.Person;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;

/**
* Acts as a controller to handle actions
Expand Down Expand Up @@ -48,7 +49,7 @@ public void validate(){

}


@StrutsParameter(depth = 1)
public Person getPersonBean() {

return personBean;
Expand Down
10 changes: 7 additions & 3 deletions form-validation/src/main/resources/struts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<constant name="struts.devMode" value="true" />

<package name="basicstruts2" extends="struts-default">

<default-action-ref name="index" />
<!-- If no class attribute is specified the framework will assume success and
render the result index.jsp -->
<!-- If no name value for the result node is specified the success value is the default -->
Expand All @@ -22,9 +22,13 @@
<result name="success">/HelloWorld.jsp</result>
</action>

<action name="registerForm" class="org.apache.struts.register.action.Register" method="input">
<result name="input">/register.jsp</result>
</action>

<action name="register" class="org.apache.struts.register.action.Register" method="execute">
<result name="success">/thankyou.jsp</result>
<result name="input">/register.jsp</result>
<result name="success">/thankyou.jsp</result>
<result name="input">/register.jsp</result>
</action>

</package>
Expand Down
5 changes: 4 additions & 1 deletion form-validation/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<web-app id="WebApp_ID" version="6.0"
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd">
<display-name>Form Validation</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
Expand Down
2 changes: 1 addition & 1 deletion form-validation/src/main/webapp/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@

</s:form>

<p><a href="register.jsp">Please register</a> for our prize drawing.</p>
<p><a href="<s:url action='registerForm' />">Please register</a> for our prize drawing.</p>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.apache.struts.edit.service.EditService;
import org.apache.struts.edit.service.EditServiceInMemory;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -38,6 +39,7 @@ public String input() throws Exception {
return INPUT;
}

@StrutsParameter(depth = 1)
public Person getPersonBean() {
return personBean;
}
Expand Down
7 changes: 4 additions & 3 deletions form-xml-validation/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<web-app id="WebApp_ID" version="6.0"
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd">
<display-name>Form XML Validation</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
Expand Down
1 change: 1 addition & 0 deletions helloworld/src/main/resources/struts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<constant name="struts.devMode" value="true"/>
<constant name="struts.action.extension" value=","/>
<constant name="struts.allowlist.packageNames" value="org.apache.struts.helloworld.model"/>

<package name="basicstruts2" namespace="/" extends="struts-default">
<default-action-ref name="index"/>
Expand Down
7 changes: 4 additions & 3 deletions helloworld/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<web-app id="WebApp_ID" version="6.0"
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd">
<display-name>Hello World Struts 2</display-name>
<welcome-file-list>
<welcome-file>/index</welcome-file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.apache.struts2.ActionSupport;
import org.apache.struts2.action.ParameterNameAware;
import org.apache.struts2.action.SessionAware;
import org.apache.struts2.interceptor.parameter.StrutsParameter;

import java.util.Map;

Expand All @@ -29,6 +30,7 @@ public String getUserName() {
return userName;
}

@StrutsParameter
public void setUserName(String userName) {
this.userName = userName;
}
Expand Down
2 changes: 2 additions & 0 deletions http-session/src/main/resources/struts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<struts>

<constant name="struts.devMode" value="true" />
<constant name="struts.allowlist.classes" value="org.apache.struts.helloworld.model.MessageStore" />

<package name="basicstruts2" extends="struts-default">

Expand All @@ -27,6 +28,7 @@

<default-interceptor-ref name="appDefault" />

<default-action-ref name="index" />
<!-- If no class attribute is specified the framework will assume success and
render the result index.jsp -->
<!-- If no name value for the result node is specified the success value is the default -->
Expand Down
5 changes: 4 additions & 1 deletion http-session/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<web-app id="WebApp_ID" version="6.0"
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd">
<display-name>HTTP Session Struts 2</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.struts.register.model.Person;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;

/**
* Acts as a controller to handle actions
Expand Down Expand Up @@ -48,7 +49,7 @@ public void validate(){

}


@StrutsParameter(depth = 1)
public Person getPersonBean() {

return personBean;
Expand Down
1 change: 1 addition & 0 deletions interceptors/src/main/resources/struts.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<package name="basicstruts2" extends="struts-default" >

<default-action-ref name="index" />
<!-- If no class attribute is specified the framework will assume success and
render the result index.jsp -->
<!-- If no name value for the result node is specified the success value is the default -->
Expand Down
5 changes: 4 additions & 1 deletion interceptors/src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<web-app id="WebApp_ID" version="6.0"
xmlns="https://jakarta.ee/xml/ns/jakartaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-app_6_0.xsd">
<display-name>Interceptors Struts 2</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.apache.struts.helloworld.model.MessageStore;
import org.apache.struts2.ActionSupport;
import org.apache.struts2.interceptor.parameter.StrutsParameter;

/**
* Acts as a Struts 2 controller that responds
Expand Down Expand Up @@ -37,6 +38,7 @@ public String getUserName() {
return userName;
}

@StrutsParameter
public void setUserName(String userName) {
this.userName = userName;
}
Expand Down
Loading