Struts Monitoring
The monitoring of struts is relatively simple, as long as you follow the steps below, there must be no problem.
The first step is to import the necessary jar packages, which are already mentioned in the previous jar package.
One is Javamelody.jar, the other is Jrobin-x.jar.
step two, you need to add monitoring filters in Web. XML
<filter> <filter-name>monitoring</filter-name> <filter-class> Net.bull.javamelody.monitoringfilter</filter-class> <init-param> <param-name>log</ param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping > <filter-name>monitoring</filter-name> <url-pattern>/*</url-pattern> </ Filter-mapping><listener> <listener-class> Net.bull.javamelody.sessionlistener</listener-class > </listener>
Create a new Struts-monitoring.xml file when integrated with STRUTS2
<? xml version= "1.0" encoding = "UTF-8" ?><! doctype struts PUBLIC "-//apache software foundation//dtd struts configuration 2.3//en " " http://struts.apache.org/ Dtds/struts-2.3.dtd " ><struts> <package name= " Default " extends = "Struts-default,json-default" > <interceptors> <interceptor name = "Monitoring" class = "Net.bull.javamelody.StrutsInterceptor" /> <interceptor-stack name = "Mystack" > <interceptor-ref name = "Monitoring" /> <interceptor-ref name = "DefaultStack" /> </interceptor-stack> </interceptors > <default-interceptor-ref name = "Mystack" /> </package></struts>
The other struts profiles inherit the default and reference Mystack as follows:
<package name = "*" extends = "default" namespace = "/" > <global-results> <result name= "Error" >page/error.html </result> </global-results> <action name= "*_*" class = "{1}action" method = "{2}" > <result name= "Index" >page/{1}/index.html </result > <result name=&nbsP; " JSON " type =" JSON " >json_result </result> <interceptor-ref name = "Mystack" /> </ Action> </package>
The above three steps, even if the configuration is finished.
If monitoring events are not triggered, such as clicking on something to respond to a jump, using struts, then the data is not monitored. Although there is a display of the corresponding picture, but the data on the image is 0,nan or the table below is empty, these are not triggered to listen to the event of the cause.
When integrating with spring, add the following information to monitor the interface:
Javamelody the monitoring of spring is at the method level, we can monitor a method of a class, so we need to use the pointcut in AOP to listen.
Here's a look at the main monitoring configuration:
The first step is still to import the necessary jar package, which says two, no longer repeat.
The second step is to load the monitoring-spring.xml and our own applicationcontext.xml configuration files.
If you want to read the spring configuration file while loading Web. XML, you need to implement a listener
<listener>2 <listener-class>3 Org.springframework.web.context.ContextLoaderListener4 </listener-class>5 </listener>
Then in Web. XML, add the spring file path. Use this context parameter to set the
<context-param> <param-name> contextconfiglocation</param-name> <param-value> Classpath:net/bull/javamelody/monitoring-spring.xml/web-inf/classes/bean.xml </ Param-value> </context-param>
The first line above defines the spring configuration file for the monitoring application, which is our own spring configuration file.
The third step, through the regular expression, the location method
<bean id= "Facademonitoringadvisor" class= "Net.bull.javamelody.MonitoringSpringAdvisor" > <property name = "Pointcut" > <bean class= "Org.springframework.aop.support.JdkRegexpMethodPointcut" > <property name = "pattern" value= "org.melody.*.*.service.*"/><!--Regular Expression--and </be An> </property></bean>
lll
Javamelody monitoring Spring, struts