在java程序中,很多时候我们希望能看到这个程序经过了哪些action,来方便我们理解这个程序,但是当我们拿到这些源程序时大多数时候都有种无法下口的感觉。这里介绍一个比较好用的方法。
对于使用struts的源程序,我们可以在其拦截器中配置一个专门用来显示其路径的拦截器。程序如下:
在struts.xml 中 我们配置拦截器:
<interceptor name="studyIntereptor" class="com.jh.jcs.common.interceptor.StudyWorkFlowInterceptor" />
在实现中:
protected String doIntercept(ActionInvocation invocation) throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
System.out.println(request.getRequestURL());
return invocation.invoke();
}
则每次经过的action都会被记录下来,我们可以在控制台上看到,更好的理解程序