【发布时间】:2011-09-24 05:34:43
【问题描述】:
我正在使用带有 jsf 2 的 spring security。我有一个过滤器来控制每个页面中的 db 访问是否正常。 :
public void doFilter(ServletRequest aReq, ServletResponse aResponse, FilterChain aChain) throws IOException,
ServletException
{
...
if(!myContext.isdbRunning())
{
mLogger.debug("System not working. Redirecting to: "+"/error.jsf");
aReq.setAttribute("errorMsj", "DB is not started. Please contact DB admin.");
aReq.getRequestDispatcher("/error.jsf").forward(aReq, aResponse);
return;
}
aChain.doFilter(aReq, aResponse);
return;
}
如果一切正常,我的 jsf 页面就会正确呈现。但是当过滤器在 db 中发现问题时,它会处理到错误页面。
aReq.getRequestDispatcher("/error.jsf").forward(aReq, aResponse);
但该页面不显示图像和其他基于 css 的东西..
spring security 是否会控制并禁止我的页面内容?还是我有错误?我该如何解决?我可以使用 Phase 监听器吗?
编辑:我的 web.xml 的一部分是
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter>
<filter-name>Gatekeeper</filter-name>
<filter-class>com.jsfsample.filter.GateKeeperFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Gatekeeper</filter-name>
<url-pattern>*.jsf</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
【问题讨论】:
-
如何将图片排除在过滤器的处理范围之外?
-
请发布您的安全上下文配置。
-
嗨,感谢您的回复,我编辑并添加了我的 web.xml,希望我没有误解您。另外,有没有可能是因为路径问题而找不到网页内容?
-
感谢您的更新,但我需要您的 applicationSecurity.xml 或者您已将其命名。定义
元素、 、 等的文件。
标签: jsf-2 spring-security servlet-filters