Struts2中自定义拦截器导致Action注入参数丢失
来源:互联网 发布:仿真软件matlab 编辑:程序博客网 时间:2024/06/04 17:52
写struts2项目时发现前台超链接中的参数无法传到action,
所有带有传递参数的均无法正常使用了,在Action中所有的参数无法被注入。
后来经过debug发现其中的页面都要先经过拦截器,而后再经过action,心想是不是拦截器将参数拦截下来,
最后发现,struts-default中,默认的拦截器引用是defaultstack,这个拦截器包传说是经过精心设计的。。所以会把所有的参数注入!
因此要更改默认拦截器,需要加上这个defaultstack
只有加上这个默认的拦截器才不会将参数拦截
<package name="users-authority" extends="struts-default"><!-- 受权限控制的Action配置 -->
<interceptors>
<interceptor name="authority" class="com.huizhi.util.interceptor.AuthorityInterceptor"/><!-- 定义包含权限检查的拦截器 -->
<interceptor-stack name="mydefault"><!-- 配置内建默认拦截器 -->
<interceptor-ref name="authority"/>
<interceptor-ref name="defaultStack"/><!-- 配置自定义的拦截器 -->
</interceptor-stack>
特别注意红色两行的顺序!先自定义再Default
所有带有传递参数的均无法正常使用了,在Action中所有的参数无法被注入。
后来经过debug发现其中的页面都要先经过拦截器,而后再经过action,心想是不是拦截器将参数拦截下来,
最后发现,struts-default中,默认的拦截器引用是defaultstack,这个拦截器包传说是经过精心设计的。。所以会把所有的参数注入!
因此要更改默认拦截器,需要加上这个defaultstack
只有加上这个默认的拦截器才不会将参数拦截
<package name="users-authority" extends="struts-default"><!-- 受权限控制的Action配置 -->
<interceptors>
<interceptor name="authority" class="com.huizhi.util.interceptor.AuthorityInterceptor"/><!-- 定义包含权限检查的拦截器 -->
<interceptor-stack name="mydefault"><!-- 配置内建默认拦截器 -->
<interceptor-ref name="authority"/>
<interceptor-ref name="defaultStack"/><!-- 配置自定义的拦截器 -->
</interceptor-stack>
</interceptors>
<action name="selectinfo" class="com.huizhi.users.action.SelectInfoAction" method="selectInfo"><!-- 查看用户个人信息 -->
<result name="success">/selectinfo.jsp</result>
<result name="input">/showInfo.jsp</result>
<result name="find">/admin/selectInfo.jsp</result>
</action>
特别注意红色两行的顺序!先自定义再Default
0 0
- Struts2中自定义拦截器导致Action注入参数丢失
- Struts2中自定义拦截器导致Action注入参数丢失
- Struts2使用自定义拦截器导致Action注入参数丢失、url参数
- Struts2 自定义拦截器时Action无法接收到参数
- struts2 在拦截器进行注入(根据Action是否实现自定义接口)
- aop在Action拦截丢失注入解决
- Struts2中自定义拦截器
- struts2 中自定义拦截器
- struts2中自定义拦截器
- Struts2中自定义拦截器
- Struts2中自定义拦截器
- struts项目,拦截器注入action参数失败的原因
- 在Struts2拦截器中获取请求action名称及参数
- 在Struts2拦截器中获取请求action名称及参数
- struts2中拦截器的全局拦截和自定义拦截
- 转--struts2自定义拦截器导致无法传参
- Struts2 In Action读书笔记二------------自定义开发拦截器
- 自定义Struts2的拦截器&自定义UserAware接口&Action中模型赋值问题&Hibernate懒加载问题
- Android SlidingMenu Fragment的简单优化
- Python(一)
- Android Selector 与 shape 的用法
- sys.stdout.wirte()不能输出服务器端传来的数据
- 数据库基准测试(Database Benchmarking) 说明
- Struts2中自定义拦截器导致Action注入参数丢失
- git简单使用流程(android studio)
- uvaoj 136 Ugly Numbers 优先队列使用
- 一种排序
- Adb-For-Test 使用 adb 命令实现元素定位等功能,用来辅助 android 测试
- linux在shell中获取时间
- 浅谈进程同步和互斥的概念
- poj2762 (Tarjan + dp找最长链)
- 四、title的用法