struts2拦截器的destory方法 struts2拦截器的destory方法在拦截器实例销毁前调用,请问这个实例在什么时候销毁啊,重新reload怎么没有调用destory方法啊? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 distroy方法是在拦截器服务方法调用完后自动调用执行来销毁这个拦截器。 拦截器是什么..是拦截你的URL地址不...你重新加载看下是重定向还是那个 public class MyInterceptor implements Interceptor{ public void destroy() { System.out.println("调用拦截器的destroy方法"); } public void init() { System.out.println("调用拦截器的init方法"); } public String intercept(ActionInvocation invocation) throws Exception { Long start = System.currentTimeMillis(); System.out.println("开始计数"); String r = invocation.invoke(); Long end = System.currentTimeMillis(); System.out.println(end - start); System.out.println("计数完毕"); System.out.println(r); return r; //顺便问一下这边为什么可以返回任意的字符串?不懂,麻烦解释下,谢谢! }}struts.xml<struts> <package name="default1" namespace="/" extends="struts-default"> <interceptors> <interceptor name="myIntcpt" class="com.wjf.action.MyInterceptor"></interceptor> </interceptors> <action name="test" class="com.wjf.action.TestAction"> <result>/success.jsp</result> <result name="add">/add.jsp</result> <interceptor-ref name="myIntcpt"></interceptor-ref> <interceptor-ref name="defaultStack"></interceptor-ref> </action> </package> </struts> struts2拦截器的destory方法在拦截器实例销毁前调用,请问这个实例在什么时候销毁啊,重新reload怎么没有调用destory方法啊?拦截器:public class MyInterceptor implements Interceptor{ public void destroy() { System.out.println("调用拦截器的destroy方法"); } public void init() { System.out.println("调用拦截器的init方法"); } public String intercept(ActionInvocation invocation) throws Exception { Long start = System.currentTimeMillis(); System.out.println("开始计数"); String r = invocation.invoke(); Long end = System.currentTimeMillis(); System.out.println(end - start); System.out.println("计数完毕"); System.out.println(r); return r; //顺便问一下这边为什么可以返回任意的字符串?不懂,麻烦解释下,谢谢! }}struts.xml<struts> <package name="default1" namespace="/" extends="struts-default"> <interceptors> <interceptor name="myIntcpt" class="com.wjf.action.MyInterceptor"></interceptor> </interceptors> <action name="test" class="com.wjf.action.TestAction"> <result>/success.jsp</result> <result name="add">/add.jsp</result> <interceptor-ref name="myIntcpt"></interceptor-ref> <interceptor-ref name="defaultStack"></interceptor-ref> </action> </package> </struts> 各位大哥大姐们帮小弟个忙啊 一个WEB请求要执行很久,如果页面转到其他地方去了,程序还会继续执行吗? JSP错误。。。。急!!!!!!! velocity struts tomcat 发生java.lang.OutOfMemoryError错误,高手进来帮忙 在jsp中如何获取客户端的浏览器信息?? 有个字符集问题,高手帮个忙! 菜鸟提问:怎么在jsp中插入自己写的类(不是包) jsp页调用java系统类的问题 新手上路,各位老大帮忙! @cacheable 注解实现类是哪个? 树状结构的web框架 如何将数据库表的字段由固定值修改为可增加的值?
public class MyInterceptor implements Interceptor{ public void destroy() {
System.out.println("调用拦截器的destroy方法");
} public void init() {
System.out.println("调用拦截器的init方法");
} public String intercept(ActionInvocation invocation) throws Exception {
Long start = System.currentTimeMillis();
System.out.println("开始计数");
String r = invocation.invoke();
Long end = System.currentTimeMillis();
System.out.println(end - start);
System.out.println("计数完毕");
System.out.println(r);
return r; //顺便问一下这边为什么可以返回任意的字符串?不懂,麻烦解释下,谢谢!
}
}struts.xml<struts>
<package name="default1" namespace="/" extends="struts-default">
<interceptors>
<interceptor name="myIntcpt" class="com.wjf.action.MyInterceptor"></interceptor>
</interceptors>
<action name="test" class="com.wjf.action.TestAction">
<result>/success.jsp</result>
<result name="add">/add.jsp</result>
<interceptor-ref name="myIntcpt"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</action>
</package>
</struts>
拦截器:
public class MyInterceptor implements Interceptor{ public void destroy() {
System.out.println("调用拦截器的destroy方法");
} public void init() {
System.out.println("调用拦截器的init方法");
} public String intercept(ActionInvocation invocation) throws Exception {
Long start = System.currentTimeMillis();
System.out.println("开始计数");
String r = invocation.invoke();
Long end = System.currentTimeMillis();
System.out.println(end - start);
System.out.println("计数完毕");
System.out.println(r);
return r; //顺便问一下这边为什么可以返回任意的字符串?不懂,麻烦解释下,谢谢!
}
}
struts.xml
<struts>
<package name="default1" namespace="/" extends="struts-default">
<interceptors>
<interceptor name="myIntcpt" class="com.wjf.action.MyInterceptor"></interceptor>
</interceptors>
<action name="test" class="com.wjf.action.TestAction">
<result>/success.jsp</result>
<result name="add">/add.jsp</result>
<interceptor-ref name="myIntcpt"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</action>
</package>
</struts>