开发者

Struts2 input values lost when calling interceptor

开发者 https://www.devze.com 2023-01-07 15:09 出处:网络
i have a problem with Struts2 This is my action configuration, before execut开发者_运维百科ing the roleDete in the Action, the interceptor is call, but after this, the values of the input are lost, t

i have a problem with Struts2

This is my action configuration, before execut开发者_运维百科ing the roleDete in the Action, the interceptor is call, but after this, the values of the input are lost, there is no id to delete, if i remove the interceptor then the id to delete exist, could some one guide me to solve this?

<action name="roleDelete" method="roleDelete" class="com.webapp.role.action.RoleAction">
  <interceptor-ref name="validateUser"/>
  <result name="input" type="tiles">usertypePage</result>
  <result name="success" type="redirect">usertypeForm</result>
</action>

Thanks


It sounds like you've defined a custom validateUser interceptor stack that doesn't include a required Struts 2 interceptor. By default, Struts 2 invokes the following interceptors on every request unless you define your own stack (as you've done):

        <interceptor-stack name="defaultStack">
            <interceptor-ref name="exception"/>
            <interceptor-ref name="alias"/>
            <interceptor-ref name="servletConfig"/>
            <interceptor-ref name="i18n"/>
            <interceptor-ref name="prepare"/>
            <interceptor-ref name="chain"/>
            <interceptor-ref name="debugging"/>
            <interceptor-ref name="scopedModelDriven"/>
            <interceptor-ref name="modelDriven"/>
            <interceptor-ref name="fileUpload"/>
            <interceptor-ref name="checkbox"/>
            <interceptor-ref name="multiselect"/>
            <interceptor-ref name="staticParams"/>
            <interceptor-ref name="actionMappingParams"/>
            <interceptor-ref name="params">
              <param name="excludeParams">dojo\..*,^struts\..*</param>
            </interceptor-ref>
            <interceptor-ref name="conversionError"/>
            <interceptor-ref name="validation">
                <param name="excludeMethods">input,back,cancel,browse</param>
            </interceptor-ref>
            <interceptor-ref name="workflow">
                <param name="excludeMethods">input,back,cancel,browse</param>
            </interceptor-ref>
        </interceptor-stack>

My advice would be to go through the above list and add them back in one at a time until you figure out which you need to properly populate your request variable. You can read more about interceptors in the Struts 2 docs.


     <interceptors>
        <interceptor name="vendorStoreInterceptor" class="br.org.myapp.actions.interceptors.VendorStoreInterceptor"></interceptor>

        <interceptor-stack name="defaultStack">
            <interceptor-ref name="exception"/>
            <interceptor-ref name="alias"/>
            <interceptor-ref name="servletConfig"/>
            <interceptor-ref name="i18n"/>
            <interceptor-ref name="prepare"/>
            <interceptor-ref name="chain"/>
            <interceptor-ref name="debugging"/>
            <interceptor-ref name="scopedModelDriven"/>
            <interceptor-ref name="modelDriven"/>
            <interceptor-ref name="fileUpload"/>
            <interceptor-ref name="checkbox"/>
            <interceptor-ref name="multiselect"/>
            <interceptor-ref name="staticParams"/>
            <interceptor-ref name="actionMappingParams"/>
            <interceptor-ref name="params">
              <param name="excludeParams">dojo\..*,^struts\..*</param>
            </interceptor-ref>
            <interceptor-ref name="conversionError"/>
            <interceptor-ref name="validation">
                <param name="excludeMethods">input,back,cancel,browse</param>
            </interceptor-ref>
            <interceptor-ref name="workflow">
                <param name="excludeMethods">input,back,cancel,browse</param>
            </interceptor-ref>
        </interceptor-stack>

        <interceptor-stack name="mainStack">
            <interceptor-ref name="vendorStoreInterceptor"/>
            <interceptor-ref name="defaultStack"/>
        </interceptor-stack>
    </interceptors>

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

--

Use that. You have to include your interceptor and the defaultStack after (watch the last 'interceptor-stack' with my 'vendorStoreInterceptor' and the 'defaultStack').

That's it!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号