运用 Struts2.16 annotation 注解方式配置拦截器的注意事项
来源:互联网 发布:配煤软件 编辑:程序博客网 时间:2024/05/17 01:09
最近在使用Struts2.16 的Annotation 的方式来配置Action 包括拦截器,其中用到了自定义的拦截器,在运行的过程中,只配了自定义的拦截器,没有将默认的拦截器配进去,结果页面中的Vo对象传过去后是个空对象,百思不得其解。
以下是刚开始出错的配置(注意 紫色 部分):
@InterceptorRefs( {
@InterceptorRef("annotationInterceptor")
})
@Service("TestAction")
@Scope("prototype")
@Namespace("/t")
@Results( {
@Result(name="listpage",location = "/WEB-INF/project/sample/index.ftl", type="freemarker"),
@Result(name="addpage",location = "/WEB-INF/project/sample/addpage.ftl", type="freemarker")
})
public class TestAction extends ActionSupport {
}
修改后的配置:注意红色的部分为新加进去的
@InterceptorRefs( {
@InterceptorRef("annotationInterceptor"),
@InterceptorRef("defaultStack")
})
@Service("TestAction")
@Scope("prototype")
@Namespace("/t")
@Results( {
@Result(name="listpage",location = "/WEB-INF/project/sample/index.ftl", type="freemarker"),
@Result(name="addpage",location = "/WEB-INF/project/sample/addpage.ftl", type="freemarker")
})
public class TestAction extends ActionSupport {
}
修改后,页面的值就可以正常传过去了。最后经过反思终于明白,原来所有的 Action 假如你没有配置拦截器的时候,其实它是指定了默认的 拦截器栈的, 默认的拦截器栈是:defaultStack 该栈里面定义了多个拦截器,相关的拦截器会对页面的对象的值进行封装打包等操作,假如你指定自定义的拦截器,那么必须要手动的将默认的拦截器加进来,否则 就会在 Action 中得不到相关对象的值,Action使用自定义拦截器时,其不会将默认的拦截器加进来的,这点必须牢牢记住.
- 运用 Struts2.16 annotation 注解方式配置拦截器的注意事项
- Struts2的注解方式Annotation
- struts2注解下的拦截器配置
- struts2基于注解的拦截器配置
- struts2注解下的拦截器配置
- Struts2 Annotation 注解配置
- Struts2 Annotation 注解配置
- Struts2 Annotation 注解配置
- Struts2 Annotation 注解配置
- Struts2 Annotation 注解配置
- Struts2拦截器的运用
- struts2注解配置注意事项
- struts2注解配置注意事项
- Struts2注解(annotation)方式下chain的设置方式
- Struts2注解(annotation)方式下chain的设置方式
- struts2 注解配置拦截器 实例
- struts2 注解配置拦截器 实例
- struts2自定义拦截器注解配置方法
- 产品功能的编写小总结
- gdb core dump文件
- C++复制构造函数和赋值操作符的区别
- Oracle常见等待事件
- win7 能装.net framework
- 运用 Struts2.16 annotation 注解方式配置拦截器的注意事项
- 一种新的图像多标记注释的图结构的稀疏模型(ICCV2013)
- 关于轻量级和重量级的问题(AWT和SWING)
- Tomcat部署项目修改浏览器上猫咪头像
- JAVA中request.getParameterMap()用法笔记
- 编程珠玑 第二章 习题6~9
- 反汇编分析工具IDA Pro的可视化插件使用方法
- bdb
- win7下安装mongodb