当我使用以下代码时,我正在测试令牌的不同场景,并遇到此问题:

<action name="sincronizar" class="action.SincronizarAction">
        <interceptor-ref name="token"/>
        <interceptor-ref name="mystack"/>
        <result name="success" type="tiles">d_sincronizar</result>
        <result name="input" type="tiles">d_sincronizar</result>
        <result name="invalid.token" type="tiles">d_sincronizar</result>
    </action>


在控制台中出现此错误:

WARNING: Error setting expression 'struts.token' with value '[Ljava.lang.String;@3584de'
ognl.OgnlException: target is null for setProperty(null, "token",
[Ljava.lang.String;@3584de)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2312)
at ognl.ASTProperty.setValueBody(ASTProperty.java:127)


现在我用“ basicStack”重拍:

<action name="sincronizar" class="action.SincronizarAction">
        <interceptor-ref name="token"/>
        <interceptor-ref name="basicStack"/>
        <result name="success" type="tiles">d_sincronizar</result>
        <result name="input" type="tiles">d_sincronizar</result>
        <result name="invalid.token" type="tiles">d_sincronizar</result>
    </action>


没问题。但我需要使用我的堆栈。另外,当我使用相同的拦截器制作新堆栈时,也会遇到相同的问题。示例:lowStack相同的basicStack http://struts.apache.org/development/2.x/docs/interceptors.html

<interceptor-stack name="lowStack">
            <interceptor-ref name="exception"/>
            <interceptor-ref name="servletConfig"/>
            <interceptor-ref name="prepare"/>
            <interceptor-ref name="checkbox"/>
            <interceptor-ref name="multiselect"/>
            <interceptor-ref name="actionMappingParams"/>
            <interceptor-ref name="params"/>
            <interceptor-ref name="conversionError"/>
     </interceptor-stack>

<action name="sincronizar" class="action.SincronizarAction">
        <interceptor-ref name="token"/>
        <interceptor-ref name="lowStack"/>
        <result name="success" type="tiles">d_sincronizar</result>
        <result name="input" type="tiles">d_sincronizar</result>
        <result name="invalid.token" type="tiles">d_sincronizar</result>
    </action>


我也有同样的问题。

最佳答案

发生这种情况是因为您缺少excludeParams拦截器的params参数。
它看起来应该像这样:

<interceptor-ref name="params">
  <param name="excludeParams">dojo\..*,^struts\..*,^session\..*,^request\..*,^application\..*,^servlet(Request|Response)\..*,parameters\...*</param>
</interceptor-ref>


看看定义了struts-default.xml拦截器的basicStack

09-26 11:53