动态获取Struts2执行动作的Method Name
来源:互联网 发布:淘宝网数据包下载 编辑:程序博客网 时间:2024/05/01 23:09
使用拦截器来实现!
package org.game.interceptor;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.apache.struts2.ServletActionContext;
import org.game.util.HibernateUtil;
/**
* 处理事务
* @author zhaolong
*/
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
@SuppressWarnings("serial")
public class HibernateInterceptor extends AbstractInterceptor {
@Override
public String intercept(ActionInvocation invocation) throws Exception {
Session session = HibernateUtil.getSession();
Transaction tx = session.beginTransaction();
System.out.println("................begin transaction................");
String result = null;
try {
result = invocation.invoke();
String name = invocation.getProxy().getMethod();
// 保存方法名
//ActionContext.getContext().put("method", name);
System.out.println("Method Name :-->" + name);
tx.commit();
System.out.println("................transaction commit................");
} catch (Exception e) {
e.printStackTrace();
tx.rollback();
}
return result;
}
}
- 动态获取Struts2执行动作的Method Name
- struts2的method执行
- 精灵的执行动作
- STRUTS2.xml配置文件中action里的name和method用途解析
- Struts2动作的搜索顺序
- 获取动态sql的执行结果
- 动态获取桩函数的执行次数
- struts2中action中的name和method意思
- Java reflect--动态执行Method-代码
- Struts2 2.5版本执行index 不执行指定method
- Struts2动作
- struts2的method="{1}"
- struts2的method="{1}"
- Struts2的method{1}用法
- struts2的method="{1}"
- Struts2的数据标签获取不到Person的name属性解决方案
- Struts2不使用自带标签库执行method方法
- new对象之后的动作---执行顺序
- Apache HTTP Server 与 Tomcat 的三种连接方式介绍
- 关于财务公司软件
- 获取手机中的图片
- Winform datagridview Excel 导入导出
- 孙鑫VC学习笔记:第五讲 文本编程
- 动态获取Struts2执行动作的Method Name
- 虚拟列表控件(CListCtrl)
- web.xml文件解析,以及tomcat启动常见错误总结一哈。
- VS2005调试技巧集合
- PHP中的if
- 简单计算器(hdu 1237)
- Linux内核spin_lock与spin_lock_irq分析
- Calf Flac
- MegaCli命令总结