解决Spring错误时如何排除sitemesh过滤器?
我有一个可以装饰页面的 Sitemesh 过滤器。我已经配置了 Spring 的 exceptionResolver
,以便所有错误都将转到名为 error
的视图,然后指向 WEB-INF/jsp/error.jsp< /code> 通过
InternalResourceViewResolver
。
现在错误页面由 sitemesh 装饰,我想将其从装饰中排除。使用 sitemesh decorator.xml
的
标签不起作用。因为传入的 url 可能与 /app/login.html
一样正常,并且 sitemesh 已经捕获它并装饰它。
我注意到,在 Spring 中,如果我有一个用于 ajax 请求的 @ResponseBody,它将绕过 Sitemesh 的装饰。我想知道它是如何工作的?我可以在 errorResolver
中做一些事情来绕过 sitemesh 吗?
I have a Sitemesh filter that will decorate pages. I have configured a Spring's exceptionResolver
so that all the error will go to a view called error
which is then pointed to WEB-INF/jsp/error.jsp
through InternalResourceViewResolver
.
Now the error page is decorated by sitemesh and I would like to exclude it from decoration. Using <exclude>
tag of sitemesh decorator.xml
does not work. Because the incoming url may be something as normal as /app/login.html
and sitemesh already catch it and decorate it.
I notice that in Spring if I have a @ResponseBody
for ajax request, it would by pass Sitemesh's decoration. I wonder how it works? Can I make something in the errorResolver
to bypass sitemesh also?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可以通过实现自己的
exceptionResolver
来完成,手动流式输出并返回 nullModelAndView
It can be done by imlementing own
exceptionResolver
, streaming output manually and return nullModelAndView
至少在 SiteMesh 3 中,这种类型的排除有效(sitemesh3.xml)
这是在 Spring 3 中尝试的。希望这对您有所帮助。
At least in SiteMesh 3 this type of exclude works (sitemesh3.xml)
This is tried in Spring 3. I hope this helped you.