This is an automated email from the ASF dual-hosted git repository. lukaszlenart pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/struts-examples.git
The following commit(s) were added to refs/heads/master by this push: new b600a63 Adjust example to expose problem with processing action: prefix Refers to WW-5238 b600a63 is described below commit b600a6301c53ad9c9e854d2b1f820377eefb0d8a Author: Lukasz Lenart <lukaszlen...@apache.org> AuthorDate: Thu Oct 6 09:38:29 2022 +0200 Adjust example to expose problem with processing action: prefix Refers to WW-5238 --- .../java/org/apache/struts/register/action/Register.java | 4 ++-- form-processing/src/main/resources/struts.xml | 14 +++++++++++--- form-processing/src/main/webapp/WEB-INF/register.jsp | 2 +- form-processing/src/main/webapp/WEB-INF/web.xml | 6 +----- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/form-processing/src/main/java/org/apache/struts/register/action/Register.java b/form-processing/src/main/java/org/apache/struts/register/action/Register.java index 98eb692..bfa99db 100644 --- a/form-processing/src/main/java/org/apache/struts/register/action/Register.java +++ b/form-processing/src/main/java/org/apache/struts/register/action/Register.java @@ -7,12 +7,12 @@ public class Register extends ActionSupport { private Person personBean; - public String execute() throws Exception { + public String execute2() throws Exception { //call Service class to store personBean's state in database return SUCCESS; } - public String cancel() throws Exception { + public String cancel2() throws Exception { return SUCCESS; } diff --git a/form-processing/src/main/resources/struts.xml b/form-processing/src/main/resources/struts.xml index 2addd1a..56f4999 100644 --- a/form-processing/src/main/resources/struts.xml +++ b/form-processing/src/main/resources/struts.xml @@ -7,7 +7,15 @@ <constant name="struts.enable.DynamicMethodInvocation" value="true"/> <constant name="struts.mapper.action.prefix.enabled" value="true"/> - <package name="basicstruts2" extends="struts-default"> + <package name="basicstruts" namespace="/" extends="struts-default"> + <default-action-ref name="index"/> + <action name="index"> + <result type="redirectAction">test/index</result> + </action> + + </package> + + <package name="basicstruts2" namespace="/test" 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 --> @@ -25,10 +33,10 @@ <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="cancel"> + <action name="register-cancel" class="org.apache.struts.register.action.Register" method="cancel2"> <result type="redirectAction">index</result> </action> - <action name="register-submit" class="org.apache.struts.register.action.Register" method="execute"> + <action name="register-submit" class="org.apache.struts.register.action.Register" method="execute2"> <result>/WEB-INF/thankyou.jsp</result> </action> </package> diff --git a/form-processing/src/main/webapp/WEB-INF/register.jsp b/form-processing/src/main/webapp/WEB-INF/register.jsp index 7750abb..5f17f61 100644 --- a/form-processing/src/main/webapp/WEB-INF/register.jsp +++ b/form-processing/src/main/webapp/WEB-INF/register.jsp @@ -9,7 +9,7 @@ <body> <h3>Register for a prize by completing this form.</h3> -<s:form action="register-submit"> +<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"/> diff --git a/form-processing/src/main/webapp/WEB-INF/web.xml b/form-processing/src/main/webapp/WEB-INF/web.xml index 90088a1..3ea49e9 100644 --- a/form-processing/src/main/webapp/WEB-INF/web.xml +++ b/form-processing/src/main/webapp/WEB-INF/web.xml @@ -3,10 +3,6 @@ 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"> <display-name>Form_Processing_Struts2_Mvn</display-name> - <welcome-file-list> - <welcome-file>index.jsp</welcome-file> - </welcome-file-list> - <filter> <filter-name>struts2</filter-name> @@ -19,7 +15,7 @@ </filter-mapping> <welcome-file-list> - <welcome-file>/index</welcome-file> + <welcome-file>test/index</welcome-file> </welcome-file-list> </web-app>