`
johnson2132
  • 浏览: 26735 次
  • 性别: Icon_minigender_1
  • 来自: 潍坊
最近访客 更多访客>>
社区版块
存档分类
最新评论

struts2 以注解的形式实现拦截器

阅读更多
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

    该例子为struts2注解与拦截器demo,利用myEclipse8.5开发,导入刚才后,自动加载所需struts2的jar包,可以直接运行,是初学struts2注解、拦截器很好的例子,保证10分钟学会2种技术,愿意分享给大家。

    struts2注解配置Action及拦截器几种不同方式写法对应的路径指向.docx

    struts2注解配置Action及拦截器几种不同方式写法对应的路径指向.docx

    使用struts拦截器+注解实现日志审计功能

    使用struts拦截器+注解实现日志审计功能 详见博客: http://blog.csdn.net/lk_blog/article/details/10248395

    Struts2 拦截器注解(二十七)

    NULL 博文链接:https://takeme.iteye.com/blog/1651417

    struts2中拦截器的使用

    Struts2在com.opensymphony.xwork2.interceptor.annotations包中定义了3个拦截器注解类型。

    Struts2 拦截器 和 Java 中的动态代理

    NULL 博文链接:https://zhouxianglh.iteye.com/blog/523783

    Struts2 in action中文版

    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 ...

    Struts2入门教程(全新完整版)

    1.概述strust2中的拦截器 28 2.自定义拦截器 28 方式一,实现Interceptor接口。 28 方式二、继承AbstractInterceptor抽象类 29 方式三、继承MethodFilterInteceptor类 30 3.使用来MethodFilterInterceptor灵活拦截 ...

    深入浅出Struts2(附源码)

    本书是广受赞誉的Struts 2优秀教程,它全面而深入地阐述了Struts 2的各个特性,并指导开发人员如何根据遇到的问题对症下药,选择使用最合适的特性。作者处处从实战出发,在丰富的示例中直观地探讨了许多实用的技术,...

    struts2 interceptor annotation plugin

    用注解(annotation)方式配置struts2 (webwork) 中action的拦截器(interceptor)

    深入浅出Struts 2 .pdf(原书扫描版) part 1

    18.3 使用DataSourceInjectorInterceptor拦截器 269 18.4 小结 273 第19章 定制结果类型 274 19.1 概述 274 19.2 编写一个自定义的结果类型 274 19.3 使用新的结果类型 277 19.4 小结 279 第20章 Velocity 280 ...

    ssh注解配置

    spring+struts2+hibernate3,开发deom,很简洁,很齐全的代码功能

    吴天雄--SpringMVC笔记.doc

    SpringMVC笔记内容:第一天(SpringMVC的概述、SpringMVC与Struts2优势分析、重要组件、运行原理、SpringMVC环境搭建、@RequestMapping注解详解、字符编码过滤器、传参形式(基本数据类型或String、对象类型、对象....

    基于SSM框架(SpringMVC + Spring + Mybatis)的图书管理系统,内附,教程,数据库脚本

    1 此系统采用了目前最流行的ssm框架,其中的spingMVC框架相对于struts2框架更灵活,更安全。 2 本项目springMVC框架采用了注解映射器,使用了...5 spring容器内部使用拦截器,以Spring AOP的方式实现事务控制管理。

    基于SSM框架(SpringMVC + Spring + Mybatis)的图书管理系统数据库.rar

    此系统采用了目前最流行的ssm框架,其中的spingMVC框架相对于struts2框架更灵活,更安全。 2 本项目springMVC框架采用了注解映射器,使用了... 5 spring容器内部使用拦截器,以Spring AOP的方式实现事务控制管理。

    struts2+spring+hibernate

    框架配置较为全面,事务,切面,各种拦截器,且都为注解式开发模式,可应用在实际项目中,如有问题,加群:428476908,此为初始版本,如果有机会,会完善前台

    SSM示例代码

    SSM课程例题1 此系统采用了目前最流行的ssm框架,其中的spingMVC框架相对于struts2框架更灵活,更安全。 2 本项目springMVC框架采用了注解映射器,... 5 spring容器内部使用拦截器,以Spring AOP的方式实现事务控制管理

Global site tag (gtag.js) - Google Analytics