当前位置: 网站首页 > JAVA > j2ee

Struts 2 Interceptors Tutorial

时间:1970-1-1 08:33:31来源: j2ee作者:admin 点击:0次 字体 [ С]

In this tutorial you will see different ways to create you own interceptor stack and associate it with the action class.

Struts 2 comes with a set of pre defined interceptors and interceptor stacks which you can use out of the box. The struts-default.xml file contains the struts-default package which defines all the interceptors and the interceptor stacks. You can use the stack that meets your need.

When you extend your package from the struts-default package by default the defaultStack will be used for all the actions in your package. This is configured in the struts-default.xml file in the following way.

1.<default-interceptor-ref name="defaultStack"/>
Let's now create our own interceptor stack. The interceptor-stack element is used to create an interceptor stack. A stack contains a group of interceptors. Each interceptor in the stack is defined using the interceptor-ref element. In this example we will create a stack similar to the defaultStack and customise the validation interceptor according to our need.

发表评论
验证码:
最新评论