关闭Struts2中的OGNL警告 [英] Turning off OGNL warnings in Struts2
问题描述
我正在尝试关闭以下警告消息
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'
我已尝试将以下内容放入我的 log4j.xml
文件中
I have tried putting the following in my log4j.xml
file
<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>
我也尝试过添加
<constant name="struts.devMode" value="false" />
到我的 struts.xml
文件。此外,我尝试将以下内容添加到 struts.xml
文件的拦截器堆栈
部分
to my struts.xml
file. Also I have tried adding the following to the interceptor-stack
section of the struts.xml
file
<interceptor-ref name="defaultStack">
<param name="excludeParams">.*?checkbox.*</param>
</interceptor-ref>
我的问题是:1)我是否错过配置? 2)如何禁用警告。
My questions are: 1) Did I do a miss configuration? 2) How do you disable the warnings.
推荐答案
excludeParams
是 params
拦截器,应该像这样引用
The excludeParams
is a property of the params
interceptor and should be referenced like this
<interceptor-ref name="defaultStack">
<param name="params.excludeParams">.*?checkbox.*</param>
</interceptor-ref>
注意,如果你使用 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. For common usage consider creating a custom interceptor stack and make it default for any action configuration.
您可以为拦截器和OGNL设置日志记录级别。使用 log4j.properties
You can set a logging level for interceptors and OGNL. Using log4j.properties
log4j.logger.com.opensymphony.xwork2.interceptor=ERROR
log4j.logger.com.opensymphony.xwork2.ognl=ERROR
这篇关于关闭Struts2中的OGNL警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!