Struts2-Convention 拦截器配置
来源:互联网 发布:燕雀焉知鸿鹄之志 编辑:程序博客网 时间:2024/06/08 20:03
- package com.longzhun.interceptor;
- import com.opensymphony.xwork2.ActionInvocation;
- import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
- /**
- * @Title: MyInterceptor.java
- * @Package com.xxxxxxx.interceptor
- * @Description: TODO(添加描述)
- * @author longzhun
- * @date 2011-9-1 下午11:02:02
- * @version V1.0
- */
- public class MyInterceptor extends AbstractInterceptor {
- @Override
- public String intercept(ActionInvocation invocation) throws Exception {
- System.out.println("default interceptor start");
- String s = invocation.invoke();
- System.out.println("default interceptor end");
- return s;
- }
- }
- package com.longzhun.interceptor;
- import com.opensymphony.xwork2.ActionInvocation;
- import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
- /**
- * @Title: OtherInterceptor.java
- * @Package com.xxxxxxxx.interceptor
- * @Description: TODO(添加描述)
- * @author longzhun
- * @date 2011-9-1 下午11:20:58
- * @version V1.0
- */
- public class OtherInterceptor extends AbstractInterceptor {
- @Override
- public String intercept(ActionInvocation invocation) throws Exception {
- System.out.println("other interceptor start");
- String s = invocation.invoke();
- System.out.println("other interceptor end");
- return s;
- }
- }
struts.xml
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
- <struts>
- <constant name="struts.convention.package.locators" value="longzhun"/>
- <constant name="struts.convention.default.parent.package" value="curd-store"/>
- <constant name="struts.convention.result.path" value="/WEB-INF/jsp/"/>
- <package name="curd-store" extends="convention-default">
- <interceptors>
- <interceptor-stack name="defaultInterceporStack">
- <interceptor-ref name="defaultInterceptor"></interceptor-ref>
- </interceptor-stack>
- <interceptor name="defaultInterceptor" class="com.xxxxxxx.interceptor.MyInterceptor"/>
- <interceptor name="otherInterceptor" class="com.xxxxx.interceptor.OtherInterceptor"></interceptor>
- </interceptors>
- <default-interceptor-ref name="defaultInterceporStack"></default-interceptor-ref>
- </package>
- </struts>
HelloWorld.java
- package com.longzhun;
- import org.apache.struts2.convention.annotation.InterceptorRef;
- import org.apache.struts2.convention.annotation.InterceptorRefs;
- import org.apache.struts2.convention.annotation.Namespace;
- import com.opensymphony.xwork2.ActionSupport;
- /**
- * @Title: HelloWorld.java
- * @Package
- * @Description: TODO(添加描述)
- * @author longzhun
- * @date 2011-8-29 下午10:22:50
- * @version V1.0
- */
- @Namespace("/helloworld")
- @InterceptorRefs({
- @InterceptorRef("otherInterceptor"),
- @InterceptorRef("defaultInterceporStack")
- })
- public class HelloWorld extends ActionSupport{
- @Override
- public String execute() throws Exception {
- System.out.println("execute ok");
- return SUCCESS;
- }
- public String haha(){
- System.out.println("haha ok");
- return "haha";
- }
- }
- Struts2-Convention 拦截器配置
- STRUTS2 Convention零配置
- Struts2拦截器配置
- struts2 拦截器配置
- Struts2配置拦截器
- 配置struts2拦截器
- Struts2拦截器配置
- struts2 拦截器配置
- Struts2拦截器配置
- struts2拦截器配置
- struts2 拦截器配置
- Struts2拦截器配置
- Struts2拦截器配置
- struts2拦截器配置
- Struts2拦截器配置
- Struts2 拦截器配置
- 简述STRUTS2 Convention零配置
- 简述Struts2 Convention零配置
- 单链表的排序思路
- 如何重置序列
- UML用例图之泛化(generalization)、扩展(extend)和包含(include)关系--UML一波流系列讲解
- Never give up!!
- easyui datagrid 点击列表头排序出现错乱的原因
- Struts2-Convention 拦截器配置
- asp.net中后台c#数组与前台js数组交互
- java使用axis调用webservice时出现Connection reset by peer: socket write error的一种解决方法
- 菜鸟初识STM32固件库文件夹
- 追溯源码解决android疑难问题1--Viewpager之notifyDataSetChanged无刷新
- linux ubuntu安装及编译环境搭建注意事项
- VB之旅-报表的制作
- VirtualBox 收缩 vdi镜像文件
- Changsha F Curve in Circle