gpt4 book ai didi

java - 我没有在 struts2 中使用 freemarker,但我看到 freemarker 生成了很多日志记录

转载 作者:行者123 更新时间:2023-12-01 09:33:29 27 4
gpt4 key购买 nike

我的 Web 应用程序使用了 struts 2 和 jsp,但我看到控制台上生成了很多 freemarker 调试消息。

我已使用 slf4j 和 log4j2 配置关闭日志记录。然而,更深入地研究配置。

看来 freemarker 包含在 struts-default 包中,通过扩展它,我也将在我的 Web 应用程序中包含 freemarker 支持。

我的 struts.xml 配置是否错误?禁用控制台输出是唯一的方法吗?

如何从我的应用程序中“删除”freemarker?

我的struts.xml

<package name="test" namespace="/" extends="struts-default">

struts-default.xml

<package name="struts-default" abstract="true" strict-method-invocation="true">
<result-types>
<result-type name="chain" class="com.opensymphony.xwork2.ActionChainResult"/>
<result-type name="dispatcher" class="org.apache.struts2.result.ServletDispatcherResult" default="true"/>
<result-type name="freemarker" class="org.apache.struts2.views.freemarker.FreemarkerResult"/>
<result-type name="httpheader" class="org.apache.struts2.result.HttpHeaderResult"/>
<result-type name="redirect" class="org.apache.struts2.result.ServletRedirectResult"/>
<result-type name="redirectAction" class="org.apache.struts2.result.ServletActionRedirectResult"/>
<result-type name="stream" class="org.apache.struts2.result.StreamResult"/>
<result-type name="velocity" class="org.apache.struts2.result.VelocityResult"/>
<result-type name="xslt" class="org.apache.struts2.views.xslt.XSLTResult"/>
<result-type name="plainText" class="org.apache.struts2.result.PlainTextResult" />
<result-type name="postback" class="org.apache.struts2.result.PostbackResult" />
</result-types>

最佳答案

Struts2 使用 THEME 从 Struts 标签生成代码;
主题模板的集合(每个标签一个);
这个模板(在struts2-core-xxx.jar ->模板中)是FreeMarker模板。

那么您不是直接使用 Freemarker(例如 in place of the JSPs ),而是 Struts2 隐式使用 Freemarker,您无法删除它。

<小时/>

XY:您的日志记录污染问题可以通过将服务器级别提升为“错误”并将应用程序提升为“调试”来解决,而不是让整个服务器进行“调试”。

关于java - 我没有在 struts2 中使用 freemarker,但我看到 freemarker 生成了很多日志记录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39202017/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com