What does the ValueStackInterceptor do?

2017-08-02 16:23 GMT+02:00 Rubens Gomes <rubens_go...@hotmail.com>:
> I noticed that the request_locale was not found, and that's fine.  However, 
> the pageUrl was found in the HttpParameters and it is not being set on the 
> action.  Below is the Action class and struts.xml:
>
>
> @SuppressWarnings("serial")
> @Results( {
>   @Result(name=Action.INPUT,
>           location="/WEB-INF/content/${device}/error.jsp",
>           type="dispatcher"),
>   @Result(name=Action.SUCCESS,
>           location="${redirectURL}",
>           type="redirect")
> } )
> public class ChangeLocaleAction extends BaseAction
> {
>     private String pageUrl;
>
>
>     public ChangeLocaleAction()
>     {
>         super();
>     }
>
>
>     @Override
>     public void validate()
>     {
>
>         if(StringUtils.isBlank(pageUrl))
>         {
>             addActionError( getText("error.urlmissing") );
>         }
>
>     }
>
>
>     @Override
>     public String execute()
>     {
>
>         try
>         {
>             pageUrl = URLDecoder.decode(pageUrl, "UTF-8");
>             HttpServletRequest request = getRequest();
>
>             if(request == null)
>             {
>                 throw new IllegalArgumentException("HTTP request not found.");
>             }
>
>             /*
>              * The redirect automatically inserts the context path.  We need
>              * to remove the context path in redirectURL to prevent duplicate
>              * contextPaths in the redirect.
>              */
>             String contextPath = request.getContextPath();
>
>             if (pageUrl.startsWith(contextPath))
>             {
>                 pageUrl = pageUrl.replaceFirst(contextPath, "");
>                 logger.debug("redirectURL set to [{}]", pageUrl);
>             }
>
>         }
>         catch(UnsupportedEncodingException ex)
>         {
>             throw new RuntimeException("error decoding url: " + pageUrl, ex);
>         }
>
>         return SUCCESS;
>     }
>
>
>     /**
>      * @return the pageUrl
>      */
>     public String getPageUrl()
>     {
>         return pageUrl;
>     }
>
>
>     /**
>      * @param pageUrl the pageUrl to set
>      */
>     public void setPageUrl(String pageUrl)
>     {
>         this.pageUrl = pageUrl;
>     }
>
>
> }
>
>
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE struts PUBLIC
>     "-//Apache Software Foundation//DTD Struts Configuration 2.5//EN"
>     "http://struts.apache.org/dtds/struts-2.5.dtd";>
>
> <struts>
>   <constant name="struts.devMode" value="true" />
>
>   <constant name="struts.action.extension" value="do" />
>
>   <constant name="struts.convention.action.packages" 
> value="com.ezlista.web.struts2.action" />
>   <constant name="struts.convention.classes.reload" value="true" />
>   <constant name="struts.convention.default.parent.package" 
> value="ezlista-package" />
>   <constant name="struts.convention.package.locators" value="action" />
>   <constant name="struts.convention.package.locators.basePackage" 
> value="com.ezlista.web.struts2" />
>   <constant name="struts.convention.result.path" value="/WEB-INF/content/"/>
>
>   <constant name="struts.custom.i18n.resources" value="messages" />
>
>   <constant name="struts.date.format" value="dd/MM/yyyy hh:mm" />
>
>   <constant name="struts.freemarker.templatesCache" value="true" />
>
>   <constant name="struts.i18n.encoding" value="UTF-8" />
>
>   <constant name="struts.serve.static" value="true" />
>
>   <constant name="struts.ui.theme" value="simple" />
>   <constant name="struts.ui.templateDir" value="template" />
>
>
>   <package name="ezlista-package" extends="json-default">
>
>     <interceptors>
>
>       <interceptor name="valueStack"
>                    
> class="com.ezlista.web.struts2.interceptor.ValueStackInterceptor" />
>
>       <interceptor-stack name="ezlistaStack">
>         <interceptor-ref name="valueStack" />
>         <interceptor-ref name="defaultStack">
>           <param name="exception.logEnabled">true</param>
>           <param name="exception.logLevel">ERROR</param>
>           <param name="exception.logCategory">com.ezlista</param>
>           <param 
> name="params.excludeParams">dojo\..*,^struts\..*,^session\..*,^request\..*,^application\..*,^servlet(Request|Response)\..*,parameters\...*,^_csrf</param>
>         </interceptor-ref>
>       </interceptor-stack>
>
>     </interceptors>
>
>     <default-interceptor-ref name="ezlistaStack" />
>
>     <default-action-ref name="default-action" />
>
>     <global-results>
>       <result name="login" type="redirectAction">/view-login.do</result>
>       <result name="error">/WEB-INF/content/${device}/error.jsp</result>
>       <result name="exception">/WEB-INF/content/${device}/error.jsp</result>
>       <result name="warning">/WEB-INF/content/${device}/warning.jsp</result>
>     </global-results>
>
>     <global-exception-mappings>
>       <exception-mapping exception="java.lang.Exception" result="exception" />
>     </global-exception-mappings>
>
>     <action name="default-action" 
> class="com.ezlista.web.struts2.action.DefaultAction" />
>
>   </package>
>
>
>   <package name="home" extends="ezlista-package" namespace="/">
>
>     <action name="about" class="com.ezlista.web.struts2.action.DummyAction">
>       <result>/WEB-INF/content/${device}/about.jsp</result>
>     </action>
>
>     <action name="help" class="com.ezlista.web.struts2.action.DummyAction">
>       <result>/WEB-INF/content/${device}/help.jsp</result>
>     </action>
>
>     <action name="language-help" 
> class="com.ezlista.web.struts2.action.DummyAction">
>       <result>/WEB-INF/content/${device}/language-help.jsp</result>
>     </action>
>
>     <action name="pending-email-help" 
> class="com.ezlista.web.struts2.action.DummyAction">
>       <result>/WEB-INF/content/${device}/pending-email-help.jsp</result>
>     </action>
>
>     <action name="privacy" class="com.ezlista.web.struts2.action.DummyAction">
>       <result>/WEB-INF/content/${device}/privacy.jsp</result>
>     </action>
>
>     <action name="remember-help" 
> class="com.ezlista.web.struts2.action.DummyAction">
>       <result>/WEB-INF/content/${device}/remember-help.jsp</result>
>     </action>
>
>     <action name="terms" class="com.ezlista.web.struts2.action.DummyAction">
>       <result>/WEB-INF/content/${device}/terms.jsp</result>
>     </action>
>
>     <action name="terms-service" 
> class="com.ezlista.web.struts2.action.DummyAction">
>       <result>/WEB-INF/content/${device}/terms-service.jsp</result>
>     </action>
>
>     <action name="view-session-timeout" 
> class="com.ezlista.web.struts2.action.DummyAction">
>       <result>/WEB-INF/content/${device}/session-timeout.jsp</result>
>     </action>
>
>   </package>
>
>
> </struts>
>
>
>
>
>
>
>
>
> ________________________________________
> From: Lukasz Lenart <lukaszlen...@apache.org>
> Sent: Wednesday, August 2, 2017 5:01 AM
> To: Struts Users Mailing List
> Subject: Re: Request Parameter not being set on Action
>
> 2017-08-02 8:34 GMT+02:00 Rubens Gomes <rubens_go...@hotmail.com>:
>> The request below is sent , but the parameters (request_locale/pageUrl) are 
>> not set on the action.
>>
>> http://localhost:8080/change-locale.do?request_locale=en&pageUrl=%2Fview-login.do
>
> The "request_locale" parameter is a special parameter that tells
> I18NInterceptor to change locale, it will be removed after that so you
> cannot access it in an action.
> If you need to access locale in an action and assuming your extending
> the ActionSupport class just call the "getLocale()" method.
>
> Regarding the "pageUrl" parameter, can you start with a simple
> example? Or maybe post your struts.xml plus an action's class?
>
>
>
> Regards
> --
> Ɓukasz
> + 48 606 323 122 http://www.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
> For additional commands, e-mail: user-h...@struts.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to