struts2的ActionEventListener
来源:互联网 发布:树熊网络wifi如何登录 编辑:程序博客网 时间:2024/05/29 13:35
ActionEventListener
一个actioneventListener可以被用作当action实例被创建或者当处理action时exception发生的时候添加一个处理逻辑。
配置
目前对于整个struts2应用只有一个ActionEventListener实例,可以通过struts.xml增加bean定义来配置:
<bean type="com.opensymphony.xwork2.ActionEventListener" class="com.demo.MyActionEventListener"/>
Examples
public class MyActionEventListener implements ActionEventListener {
public Object prepare(Object action, ValueStack stack) {
if (action instanceof MyBaseAction) {
((MyBaseAction)action).setUserService(stack.findValue("userService"));
}
}
public String handleException(Throwable t, ValueStack stack) {
if (t instanceof MyBusinessException) {
return stack.findString("defaultBusinesResult");
}
return null;
}
一个actioneventListener可以被用作当action实例被创建或者当处理action时exception发生的时候添加一个处理逻辑。
配置
目前对于整个struts2应用只有一个ActionEventListener实例,可以通过struts.xml增加bean定义来配置:
<bean type="com.opensymphony.xwork2.ActionEventListener" class="com.demo.MyActionEventListener"/>
Examples
public class MyActionEventListener implements ActionEventListener {
public Object prepare(Object action, ValueStack stack) {
if (action instanceof MyBaseAction) {
((MyBaseAction)action).setUserService(stack.findValue("userService"));
}
}
public String handleException(Throwable t, ValueStack stack) {
if (t instanceof MyBusinessException) {
return stack.findString("defaultBusinesResult");
}
return null;
}
}
翻译自http://struts.apache.org/docs/actioneventlistener.html
0 0
- struts2的ActionEventListener
- struts2的%{ }
- struts2的%{ } # $
- Struts2的struts2.xml配置文件
- Struts2(1):Struts2的配置文件
- 【Struts2】①Struts2的入门
- Struts2-----3、Struts2的流程
- 【struts2】Struts2的运行流程
- 【Struts2】:Struts2的类型转换
- 【struts2】struts2的开发步骤
- 【struts2】Struts2的运行流程
- [Struts2]Struts2的文件上传
- struts2-struts2的基本配置
- Struts2概述,Struts1的Struts2的区别
- 初学struts2的一点笔记(struts2.1.6、struts2.2.1)
- Struts2学习笔记17:Struts2的国际化
- Struts2使用2-- Struts2的概述
- Struts2系列——struts2的result
- struts2的Action Chaining
- Git 的基本使用步骤
- MyBatis 一对多双向关联查询
- Android开发--倒计时的实现
- EJB3.x:部署(卸载)EntityBean时自动创建(删除)表结构
- struts2的ActionEventListener
- JavaScript 对象的创建
- ListView的新朋友-------RecyclerView初识
- Q9.4 Write a method that returns all subsets of a set.
- libcurl 使用及例程
- 数组名和数组名取地址的区别
- C#中转义符和@符号的作用
- cygwin下安装mbsystem-5.4.2209 configure部分
- HDU 5105 Math Problem(数学)