简体   繁体   English

在 Struts 2 中关闭 OGNL 警告

[英]Turning off OGNL warnings in Struts 2

I am trying to turn off the following warning message我正在尝试关闭以下警告消息

OgnlValueStac W com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn Error setting expression 'checkboxidentifyer' with value '[Ljava.lang.String;@518b518b'

I have tried putting the following in my log4j.xml file我尝试将以下内容放入我的log4j.xml文件中

<logger name="log4j.logger.org.apache.struts2" >
    <level value="ERROR" />
    <appender-ref ref="console" />
</logger>
<logger name="log4j.logger.com.opensymphony" >
  <level value="ERROR" />
  <appender-ref ref="console" />
</logger>
<logger name="ognl.OgnlException" >
  <level value="ERROR" />
     <appender-ref ref="console" />
</logger>
<logger name="com.opensymphony.xwork2.util.logging.commons.CommonsLogger" >
  <level value="ERROR" />
  <appender-ref ref="console" />
</logger>
<logger name="ognl.OgnlRuntime" >
  <level value="ERROR" />
  <appender-ref ref="console" />
</logger>

I have also tried adding我也试过添加

<constant name="struts.devMode" value="false" />

to my struts.xml file.到我的struts.xml文件。 Also I have tried adding the following to the interceptor-stack section of the struts.xml file我也尝试将以下内容添加到struts.xml文件的interceptor-stack部分

<interceptor-ref name="defaultStack">
    <param name="excludeParams">.*?checkbox.*</param>
</interceptor-ref>

My questions are:我的问题是:

  1. Did I do a miss configuration?我做错了配置吗?
  2. How do you disable the warnings.你如何禁用警告。

The excludeParams is a property of the params interceptor and should be referenced like this excludeParamsparams拦截器的一个属性,应该像这样引用

<interceptor-ref name="defaultStack">
    <param name="params.excludeParams">.*?checkbox.*</param>
</interceptor-ref>

Note, if you use interceptor-ref tag on the action then it overrides the default interceptor stack and applicable only to this action config.请注意,如果您在操作上使用interceptor-ref标记,那么它会覆盖默认的拦截器堆栈并且仅适用于此操作配置。 For common usage consider creating a custom interceptor stack and make it default for any action configuration.对于常见用法,请考虑创建自定义拦截器堆栈并将其设为任何操作配置的默认值。

You can set a logging level for interceptors and OGNL.您可以为拦截器和 OGNL 设置日志记录级别。 Using log4j.properties使用log4j.properties

log4j.logger.com.opensymphony.xwork2.interceptor=ERROR
log4j.logger.com.opensymphony.xwork2.ognl=ERROR

I finnaly sovled the error, while I had (as seen in the question above the param in the defaultStack interceptor-ref, when I moved the param to the interceptor-ref name params it removed the error我最终解决了错误,而我有(如在 defaultStack 拦截器引用中的参数上方的问题中所见,当我将参数移动到拦截器引用名称 params 时,它删除了错误

<interceptor-stack name="new_default_stack">
  <interceptor-ref name="params">
  <param name="paramNameMaxLength">250</param>
  <param name="excludeParams">.*?checkbox.*</param>
  </interceptor-ref>
  <interceptor-ref name="timeActions"/>
  <interceptor-ref name="defaultStack">

  </interceptor-ref>
  <interceptor-ref name="userProfile"/>
  <interceptor-ref name="valueStackManipulator"/>
  <interceptor-ref name="actionHistoryRecorder"/>
  <interceptor-ref name="cachingHeadersInterceptor"/>
</interceptor-stack>

it was the location of the excludeParams that needed to be changed.这是需要更改的 excludeParams 的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM