package com.example.struts.action;
import java.util.Map;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.interceptor.annotations.*;
public class LoginAction extends ActionSupport {
private String username;
@Before
public void myBefore() {
System.out.println("调用myBefore方法");
// return LOGIN;
}
@After
public void myAfter() throws InterruptedException {
Thread.sleep(5000);
System.out.println("----调用myAfter方法");
}
@BeforeResult
public void myBeforeResult() {
System.out.println("----调用myBeforeResult方法");
}
public String execute() throws Exception {
System.out.println("调用execute方法");
return SUCCESS;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
System.out.println("---调用set方法" + username);
this.username = username;
}
}
<package name="ano" extends="struts-default">
<interceptors>
<interceptor name="anno" class="com.opensymphony.xwork2.interceptor.annotations.AnnotationWorkflowInterceptor">
</interceptor>
<interceptor-stack name="annoStack">
<interceptor-ref name="anno"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>
<action name="login" class="com.example.struts.action.LoginAction">
<result name="success">/success.jsp</result>
<result name="login">/login.jsp</result>
<interceptor-ref name="annoStack"></interceptor-ref>
</action>
<action name="index">
<result>/login.jsp</result>
</action>
</package>
分享到:
相关推荐
该例子为struts2注解与拦截器demo,利用myEclipse8.5开发,导入刚才后,自动加载所需struts2的jar包,可以直接运行,是初学struts2注解、拦截器很好的例子,保证10分钟学会2种技术,愿意分享给大家。
struts2注解配置Action及拦截器几种不同方式写法对应的路径指向.docx
使用struts拦截器+注解实现日志审计功能 详见博客: http://blog.csdn.net/lk_blog/article/details/10248395
NULL 博文链接:https://takeme.iteye.com/blog/1651417
Struts2在com.opensymphony.xwork2.interceptor.annotations包中定义了3个拦截器注解类型。
NULL 博文链接:https://zhouxianglh.iteye.com/blog/523783
4.3 研究内建的Struts 2拦截器 67 4.3.1 工具拦截器 67 4.3.2 数据转移拦截器 67 4.3.3 工作流拦截器 69 4.3.4 其他拦截器 72 4.3.5 内建的拦截器栈 73 4.4 声明拦截器 74 4.4.1 声明独立的拦截器和拦截器栈 74 ...
1.概述strust2中的拦截器 28 2.自定义拦截器 28 方式一,实现Interceptor接口。 28 方式二、继承AbstractInterceptor抽象类 29 方式三、继承MethodFilterInteceptor类 30 3.使用来MethodFilterInterceptor灵活拦截 ...
本书是广受赞誉的Struts 2优秀教程,它全面而深入地阐述了Struts 2的各个特性,并指导开发人员如何根据遇到的问题对症下药,选择使用最合适的特性。作者处处从实战出发,在丰富的示例中直观地探讨了许多实用的技术,...
用注解(annotation)方式配置struts2 (webwork) 中action的拦截器(interceptor)
18.3 使用DataSourceInjectorInterceptor拦截器 269 18.4 小结 273 第19章 定制结果类型 274 19.1 概述 274 19.2 编写一个自定义的结果类型 274 19.3 使用新的结果类型 277 19.4 小结 279 第20章 Velocity 280 ...
spring+struts2+hibernate3,开发deom,很简洁,很齐全的代码功能
SpringMVC笔记内容:第一天(SpringMVC的概述、SpringMVC与Struts2优势分析、重要组件、运行原理、SpringMVC环境搭建、@RequestMapping注解详解、字符编码过滤器、传参形式(基本数据类型或String、对象类型、对象....
1 此系统采用了目前最流行的ssm框架,其中的spingMVC框架相对于struts2框架更灵活,更安全。 2 本项目springMVC框架采用了注解映射器,使用了...5 spring容器内部使用拦截器,以Spring AOP的方式实现事务控制管理。
此系统采用了目前最流行的ssm框架,其中的spingMVC框架相对于struts2框架更灵活,更安全。 2 本项目springMVC框架采用了注解映射器,使用了... 5 spring容器内部使用拦截器,以Spring AOP的方式实现事务控制管理。
框架配置较为全面,事务,切面,各种拦截器,且都为注解式开发模式,可应用在实际项目中,如有问题,加群:428476908,此为初始版本,如果有机会,会完善前台
SSM课程例题1 此系统采用了目前最流行的ssm框架,其中的spingMVC框架相对于struts2框架更灵活,更安全。 2 本项目springMVC框架采用了注解映射器,... 5 spring容器内部使用拦截器,以Spring AOP的方式实现事务控制管理