Struts2的监听器:
一,建立监听器:
实现com.opensymphony.xwork2.interceptor.PreResultListener接口
public class MyListener implements PreResultListener {
public void beforeResult(ActionInvocation actionInvocation, String resultCode) {
System.out.println("监听器:"+resultCode);
}
}
二,注册监听器(要在拦截器中注册临听器)
public class MyInterceptor extends AbstractInterceptor {
@Override
public String intercept(ActionInvocation actionInvocation) throws Exception {
/**
* 注册监听器
*/
actionInvocation.addPreResultListener(new MyListener());
System.out.println("拦截器之前");
String result = actionInvocation.invoke();
System.out.println("拦截器之后");
return result;
}
}
三,监听器是在Action里的方法执行完后,在出拦截器方法之前执行!
分享到:
相关推荐
STRUTS:listener监听器
默认登录页面 http://localhost:8080/Struts_ljq ...登录成功页面有add,delete,modify方法,配置有不同拦截,在后台看拦截信息。...有全局拦截器配置和方法拦截,及监听器简单运用, 仅新手学习demo
该属性指定Struts 2使用的FreeMarker管理器.该属性的默认值是org.apache.struts2.views.freemarker.FreemarkerManager,这是Struts 2内建的FreeMarker管理器. struts.freemarker.wrapper.altMap 该属性只支持true和...
3.配置spring的监听器: 在web.xml中添加 org.springframework.web.context.ContextLoaderListener 4.配置spring的配置文件(可以查看WEB-INF里面的applicationContext.xml文件) 注意:如果是默认...
web容器中(web.xml)中添加struts2 filter以及spring 监听器。 b 在struts.xml中添加action,使用通配符的方式 , 注意这里和单独struts2不同的地方: class属性指向的是bean 的 id ,这里我们配置bean采用spring ...
导入struts2-spring-plugin包,在web.xml中设置spring的监听器, spring监听器对应的API类为:org.springframework.web.context.ContextLoaderListener。 struts2-spring-plugin包为我们将struts2的对象工厂设置为...
该属性指定Struts 2使用的FreeMarker管理器。该属性的默认值是org.apache.struts2.views.freemarker.FreemarkerManager,这是Struts 2内建的FreeMarker管理器。 struts.freemarker.wrapper.altMap 该属性只支持...
数据库包括用户表和文件表,项目主体由Struts2框架搭建,前台jsp页面表单使用OGNL标签,XX_zh_CN(en_US).properties文件实现中英文国际化,XXAction-validation.xml实现表单校验,MD5加密文件绝对路径,保护文件安全...
Struts2学习文档,Struts入门学习资料,包括(struts-xml,action,上传下载,监听器,拦截器,验证,类型转换,国际化等等)
NULL 博文链接:https://takeme.iteye.com/blog/1651508
①在web.xml中配置ApplicationContext.xml,并使用ContextLoader监听器实例化spring容器 ②把action交给spring管理,即在spring配置文件中定义action Bean并使用依赖注入功能在action中注入业务Bean,同时修改作用域...
struts2课件 很好的struts2当输入login.jsp访问jsp页面填写完相关信息并提交给login.action时,它会首先被在web.xml中配置的过滤器监听到,过滤器会去查找strust.xml文件,并结合namespace查找名为login的action,...
学习常用知识(java,sql,oracle,ejb,ssh,struts,xml,监听器,拦截器,过滤器等等)这些都是本人的学习心得非常适用,希望能该初学者带来更大的帮助!!!
第2篇为基础篇,内容包括Servlet技术、JSP技术、会话跟踪、过滤器Filter、监听器Listener等;第3篇为高级篇,内容包括JSTL标签库的使用、如何自定义标签、资源国际化、数据库概述、JDBC详解、XML概述等;第4篇为...
Struts2+Spring3+hibernate3全注解,操作oracle emp表的查询
1、proxool官网,下载最新的proxool-0.9.1.jar ...4、整合Struts2、Spring和proxool,配置Web服务启动配置文件[web.xml] 5、整合Spring和proxool,配置应用上下文配置文件[applicationContext.xml]
Struts2.0 实现文件上传进度 原理和实现 主要是实现Struts2.0的监听器
1.新建工程,加入所需要的包; 2.配置sturts.xml; 3.配置Spring监听器; 4.Spring配置文件; .......
监听器配置,java监听器,登陆监听,Listener,struts监听器配置,用户在线统计 所谓线程(或称线索,thread),指程序中的以单一的顺序控制流。线程按顺序执行,即在一个线程中,一个时刻只能由一个执行点。显然...