带有 Struts 2 的 Javamelody.没有映射用于监控的操作 [英] Javamelody with Struts 2 . No action mapped for monitoring
问题描述
我有一个在 Wildfly 10 上运行的 Struts 2、Java 8 Web 应用程序,并且想要集成 Javamelody,但是无论我在 web.xml 和 struts.xml 中的配置如何,我都无法访问监控页面
I got a Struts 2 , Java 8 web application running on Wildfly 10 and wanted to integrate Javamelody but i am unable to access the monitoring page no matter my configuration in the web.xml and struts.xml
我使用以下maven依赖
I use the following maven dependency
<dependency>
<groupId>net.bull.javamelody</groupId>
<artifactId>javamelody-core</artifactId>
<version>1.77.0</version>
</dependency>
在我的 web.xml (web-app version="3.0" ) 中,我有以下配置:
In my web.xml (web-app version="3.0" ) i have the following configuration:
<filter>
<filter-name>monitoring</filter-name>
<filter-class>net.bull.javamelody.MonitoringFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>monitoring</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ASYNC</dispatcher>
</filter-mapping>
<listener>
<listener-class>net.bull.javamelody.SessionListener</listener-class>
</listener>
在我的 struts 配置中如下
In my struts configuration following
<interceptor-stack name="myStack">
<interceptor-ref name="monitoring"/>
<interceptor-ref name="defaultStack"/>
</interceptor-stack>
并将 myStack 设置为默认值
and set myStack as default
<default-interceptor-ref name="myStack" />
当我尝试访问 http://localhost:8080/myapp/monitoring 我得到以下信息错误:[org.apache.struts2.dispatcher.Dispatcher](默认任务3)找不到动作或结果:没有为命名空间/和动作名称监控映射的动作.- [未知地点]
When i try to access http://localhost:8080/myapp/monitoring i get following error: [org.apache.struts2.dispatcher.Dispatcher] (default task-3) Could not find action or result: There is no Action mapped for namespace / and action name monitoring. - [unknown location]
我在网上找不到很多关于这个问题或 Struts 配置的资源.有什么想法吗?
I cannot find many resources on the web concerning this issue or configuration with Struts . Any ideas ?
注意:我更近了一步,但我不明白为什么会发生这种情况.我必须删除所有具有 url-pattern/* 的过滤器才能使其工作.有解决方法吗?当然,使用此配置,我无法再访问我的任何页面.
Note: I am one step closer, but i don't get why this is happening. I had to remove all filter that had a url-pattern /* for this to work. Is there a workaround on this? Of course with this configuration i cannot access any of my pages anymore.
推荐答案
javamelody 用户指南 说在 servlet 之前在 WEB-INF/web.xml 中编写 javamelody MonitoringFilter.但在 Struts 2 的情况下,不再有 servlet,Struts 2 由过滤器控制.
The javamelody user's guide says to write the javamelody MonitoringFilter in WEB-INF/web.xml before your servlet. But in the case of Struts 2, there is no more servlet and Struts 2 is controlled by a filter.
因此您必须在 Struts 2 过滤器之前在 WEB-INF/web.xml 中编写 javamelody MonitoringFilter.
So you have to write the javamelody MonitoringFilter in WEB-INF/web.xml before your Struts 2 filter.
这篇关于带有 Struts 2 的 Javamelody.没有映射用于监控的操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!