質問

I have a following interceptor stack defined

    <interceptor-stack name="applicationStack">
            <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-ref name="contextSecurityInterceptor" />
    </interceptor-stack>

with this values from the UI are not getting submitted to the action, because of which "required" validation always fails. if i change the order of interceptor to "workflow" first then "validation" as, values does get submitted and action gets executed without validating values. what should be order of interceptors to keep the validation and data submission in order.

struts.xml

    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE struts PUBLIC
        "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
        "http://struts.apache.org/dtds/struts-2.0.dtd">
    <struts>
        <constant name="struts.objectFactory" value="spring" />
        <constant name="struts.devMode" value="false" />

        <constant name="struts.action.extension" value="action" />

        <constant name="struts.custom.i18n.resources" value="global" />

        <package name="org" namespace="/"
            extends="struts-default,json-default">

            <result-types>
                <result-type name="tiles"
                    class="org.apache.struts2.views.tiles.TilesResult" />
            </result-types>

            <global-results>
                <result name="welcome" type="tiles">welcome</result>
            </global-results>

        </package>

        <package name="org.unsecureActions" extends="org">
            <!--
                This package contains such a actions which doesn't need user logged
                in.
            -->

            <action name="welcome" method="forwardAction" class="baseAction">
                <result name="success" type="tiles">welcome</result>
            </action>

            <action name="logoutCandidate" method="logoutCandidate" class="logoutAction">
                <result name="success" type="tiles">welcome</result>
            </action>

            <action name="loadAdvanceSearchForm" method="loadAdvanceSearch"
                class="advanceSearchAction">
                <result name="success" type="tiles">advanceSearch</result>
            </action>

            <!--Candidate workflow  actions -->
            <action name="registerCandidateStep1" class="candidateAction"
                method="registerCandidateStep1">
                <result name="input" type="tiles">registerCandidate</result>
                <result name="success" type="tiles">registerCandidate</result>

            </action>

            <action name="registerCandidateStep2" class="candidateAction"
                method="registerCandidateStep2">
                <result name="input" type="tiles">registerCandidate</result>
                <result name="success" type="tiles">registerCandidate</result>

            </action>
            <action name="registerCandidateStep3" class="candidateAction"
                method="registerCandidateStep3">
                <result name="input" type="tiles">registerCandidate</result>
                <result name="success" type="chain">
                    <param name="actionName">loginCandidate</param>
                    <param name="namespace">/org.unsecureActions</param>
                </result>
            </action>

            <action name="loadCandidateRegistrationForm" class="loadCandidateFromAction"
                method="loadCandidateRegistrationForm">
                <result name="success" type="tiles">registerCandidate</result>
            </action>
            <!--Candidate workflow  actions -->

            <action name="loginCandidate" class="loginAction" method="loginCandidate">
                <result name="success" type="tiles">home</result>
                <result name="input" type="tiles">welcome</result>
            </action>

        </package>

        <package name="org.secureActions" extends="org">
            <!--
                This package contains such a actions which needs user must logged in
                before executing these.
            -->


            <action name="home" method="forwardAction" class="baseAction">
                <result name="success" type="tiles">home</result>
            </action>

            <action name="loadAdvanceSearchForm" method="loadAdvanceSearch"
                class="advanceSearchAction">
                <result name="success" type="tiles">advanceSearch</result>
            </action>

            <action name="simpleSearch" method="simpleSearch" class="simpleSearchAction">
                <result name="success" type="tiles">search</result>
                <result name="input" type="tiles">home</result>
            </action>

            <action name="advanceSearch" method="advanceSearch" class="advanceSearchAction">
                <result name="success" type="tiles">search</result>
            </action>
            <action name="loadImage" method="loadImage" class="imageAction">
                <result name="imageData" type="stream">
                    <param name="contentType">${imageContentType}</param>
                    <param name="inputName">imageStream</param>
                    <param name="contentDisposition">filename="candidate.jpeg"</param>
                    <param name="bufferSize">${myBufferSize}</param>
                </result>
            </action>

        </package>

    </struts>
役に立ちましたか?

解決

Neither the "validation" nor "workflow" interceptors are responsible for setting parameters on the action, that's done by the "params" interceptor.

"Workflow" only makes sense after "validation" because it checks to see if any errors are present on the action, and if there are, goes to the input result (by default).

The configuration you show is the default configuration plus your interceptor (which is suspiciously towards the end for something called "security").

If you're not seeing values being set on the action then something else is wrong, because the default configuration works as-is--so it's either something with your interceptor, the existing application flow, etc.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top