struts 拦截器 初始化参数问题

csdnduogui 2015-07-10 06:13:16
拦截器:
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
public class TestInterceptor implements Interceptor{
private String hello;
public void setHello(String hello) {
this.hello = hello;
}
public String intercept(ActionInvocation arg0) throws Exception {
System.out.print("hello:" + this.hello);
return arg0.invoke();
}
public void init() {
}
public void destroy() {
}
}

配置文件:
<interceptors>
<interceptor name="testInterceptor" class="com.xxx.interceptor.TestInterceptor">
<param name="hello">world</param>
</interceptor>
</interceptors>
<!-- 转向 -->
<action name="next" class="com.xxx.common.action.NextAction">
<!-- 定义逻辑视图和物理资源之间的映射 -->
<result name="success">${address}</result>
<interceptor-ref name="testInterceptor">
<param name="hello">world</param>
</interceptor-ref>
<interceptor-ref name="myDefaultStack"/>
</action>
怎么这个hello打死都传不过去呢,有什么没考虑到么?求大家指点。。
hello:null
...全文
145 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
csdnduogui 2015-07-12
  • 打赏
  • 举报
回复
引用 1 楼 panda_zhu 的回复:
你自定义的拦截器在配置文件里先声明一下,然后自定义一个拦截器栈,把你的拦截器和默认拦截器栈都加入进去,最后再讲容器默认拦截器栈改成你自定义的试一试。
struts 用的是2.1.8.1,而xwork版本低了,换成2.3.24后有新情况出现,我会开新帖说明,多谢。
panda_zhu 2015-07-11
  • 打赏
  • 举报
回复
你自定义的拦截器在配置文件里先声明一下,然后自定义一个拦截器栈,把你的拦截器和默认拦截器栈都加入进去,最后再讲容器默认拦截器栈改成你自定义的试一试。
概述...............................................................................................................................3
Framework概念...........................................................................................................3
Struts的概念和体系结构.............................................................................................4
Struts的与Web App的关系.......................................................................................................4
Struts的体系结构.....................................................................................................................4
从视图角度(View)......................................................................................................5
从模型角度(Model)....................................................................................................5
从控制器角度(Controller)..........................................................................................5
Struts的基本组件包.................................................................................................................5
Struts framework的工作原理和组件.........................................................................6
Struts ActionServlet控制器对象...............................................................................................7
Struts Action Classes.................................................................................................................7
Struts Action Mapping..............................................................................................................8
使用ActionForward导航..........................................................................................................9
Struts ActionForm Bean捕获表单数据..................................................................................10
Struts的其他组件...................................................................................................................11
Validation Framework for Struts.....................................................................................11
Struts TagLib...................................................................................................................11
BeanUtils........................................................................................................................11
Collections.....................................................................................................................12
Digester..........................................................................................................................12
Struts配置文件简介...................................................................................................12
有关Struts Controller及其相关的的配置描述......................................................................12
有关struts tag lib的配置描述.................................................................................................13
有关Struts Action Mapping的配置描述................................................................................13
Form-bean元素...............................................................................................................14
Action元素......................................................................................................................14
Struts高级特性(Struts Advanced Feature).........................................................16
验证........................................................................................................................................16
使用异常处理声明.................................................................................................................18
使用应用模块(Application Modules)...............................................................................20
把JSP放到WEB-INF后以保护JSP源代码............................................................................21
使用 Prebuilt Action类提升开发效率..................................................................................22
Struts标记库...............................................................................................................24
定制JSP标记...........................................................................................................................24
资源束....................................................................................................................................25
Bean标记...............................................................................................................................26
Bean复制标记................................................................................................................26
定义脚本变量的标记.....................................................................................................27
显示Bean属性................................................................................................................28
消息标记和国际化.........................................................................................................28
逻辑标记................................................................................................................................29
条件逻辑.........................................................................................................................29
重复标记.........................................................................................................................31
转发和重定向标记.........................................................................................................32
HTML标记.............................................................................................................................33
显示表单元素和输入控件.............................................................................................33
显示错误信息的标记.....................................................................................................37
其他HTML标记.............................................................................................................38
模板标记................................................................................................................................38
一个简单的示例.........................................................................................................40
Struts的安装...........................................................................................................................40
第一个实验:简单的JSP页...................................................................................................40
第二个实验:struts的国际化................................................................................................41
struts中的Forms......................................................................................................................44
struts:介绍ActionForm...........................................................................................................48
分离Book和BookForm的一个好方法...................................................................................50

81,122

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧