在注释Struts2的拦截令牌 [英] Struts2 token interceptor in annotation
本文介绍了在注释Struts2的拦截令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用的是令牌interceptor.How支柱2.3.1我可以使用令牌在拦截基于注解类行动(convension)。
I'm using struts 2.3.1 with token interceptor.How can i use token interceptor in annotation(convension) based Action Class.
这是我的struts.xml
here is My struts.xml
<action name="tokenAction" class="roseindia.action.TokenAction">
<interceptor-ref name="token" />
<interceptor-ref name="basicStack"/>
<result name="success" >/success.jsp</result>
<result name="invalid.token">/index.jsp</result>
任何一个可以告诉基于对同一个注释。
can any one please tell annotation based for the same.
推荐答案
它看起来对我来说,这是文档<在一个相当明确的href=\"http://struts.apache.org/release/2.1.x/docs/convention-plugin.html#ConventionPlugin-InterceptorRefannotation\"相对=nofollow>这里,你需要做的是:
It looks to me like this is fairly clear in the documentation here, you need to do this:
package com.example.actions;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Actions;
@InterceptorRefs({
@InterceptorRef("token"),
@InterceptorRef("basicStack")
})
@Results({
@Result(name="success", location="/success.jsp")
@Result(name="invalid.token", location="/index.jsp")
})
public class HelloWorld extends ActionSupport {
@Action(interceptorRefs={
@InterceptorRef("token"),
@InterceptorRef("basicStack")
})
public String myActionMethod() {
//do stuff
return SUCCESS;
}
}
这篇关于在注释Struts2的拦截令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文