今天刚学习拦截器的时候,书上说使用内置的 timer 可以打印出执行时间:
<package name="helloworld" extends="struts-default">
<action name="HelloWorldAction" class="com.pm.ssh.HelloWorldAction">
<result name="success">/helloname.jsp</result>
<result name="error">/error.jsp</result>
<interceptor-ref name="completeStack"/>
<interceptor-ref name="timer"/>
</action>
</package>
但我使用 struts-2.5.10-min-lib.zip 的包时,运行报错:
ERROR StatusLogger Log4j2 could not find a logging implementation. Please add log4j-core to the classpath. Using SimpleLogger to log to the console
错误很明显是缺包,因为 struts-2.5.10-min-lib.zip 中只提供了 log4j-api-2.7,并没有提供 log4j-core 包。可以去 http://logging.apache.org/ 下载。
导入运行后,还是报错:ERROR StatusLogger No log4j2 configuration file found,因为还没有配置 log4j2,那么就进行配置呗,在 src 目录下新建 log4j2.xml,进行最基本的配置,这里是打印 info 往后级

在学习Struts 2的timer拦截器时,遇到因缺少log4j-core包导致的运行错误。解决方法是下载完整的log4j2库并配置log4j2.xml文件,确保info级别及以上日志能正常输出。经过配置后,问题得到解决。
最低0.47元/天 解锁文章
13

被折叠的 条评论
为什么被折叠?



