`

struts 拦截器 使用

阅读更多
在action上加拦截器的时候,一定要先加
@InterceptorRef("defaultStack")

不然会抛异常,哪个异常我忘记了。。。

下面是防止重复提交的过滤器
当然页面中要加<s:token></s:token>
@Action(interceptorRefs = {@InterceptorRef("defaultStack"), @InterceptorRef("token")},
			value = "quickReply", results = {
			@Result(name = Constants.SUCCESS, location = "/post.jsp")})


//token验证失败
	public static final String INVALIDTOKEN = "invalid.token";



在整个action的class中加过滤器
@Scope("prototype")
@Controller
@Results( { @Result(name = Constants.SHOW_ERROR, location = "/errorMessage.jsp"),
			@Result(name = Constants.INVALIDTOKEN, location = "/tokenErrMsg.jsp")})
@ParentPackage("default")
@InterceptorRefs(value = {@InterceptorRef("defaultStack"), @InterceptorRef("sessionTimeoutInterceptor") })
@ExceptionMappings( {
		@ExceptionMapping(exception = "java.lang.Exception", result = Constants.SHOW_ERROR),
		@ExceptionMapping(exception = "com.community.exception.DataAccessException", result = Constants.SHOW_ERROR) })
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics