2

是否可以集成 Spring Security 3 和 JSF 2,保持 JSF 默认工作,而不是在用户导航时显示新 url,保留旧 url,而不使用重定向JSF 属性来导航页面?

我找不到有关此的文档。我发现作者的所有文章在导航时都会重定向页面。

谢谢

4

1 回答 1

1

默认情况下,FilterSecurityInterceptor 只会对每个请求执行一次,并且不会进行安全重新检查,除非 url 发生变化,但是使用 JSP/JSF 转发页面将呈现为对当前请求的响应,并且 url 在浏览器包含上一页的地址。因此,为此只需在 applicationContext 中的 http 元素中将每个请求属性设置为 false ,从而强制重新检查安全性。

<http auto-config="true" use-expressions="true" once-per-request="false">

并在您的 web.xml 中的 springSecurityFilterChain 过滤器映射中添加转发调度程序

<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
</filter-mapping>

更多信息

或者,您也可以通过将参数 faces-redirect=true 附加到结果中来启用页面重定向,如下所示:

<h:form>
    <h:commandButton action="page1?faces-redirect=true" value="Page1" />
</h:form>

但请记住,在您的情况下,GET 请求看起来更合适,正如BalusC所说,使用 POST 进行可书签的页面到页面导航并不是一个好习惯。

使用<h:link>or<h:button>或 faces-redirect=true 的 GET 也会导致 GET 请求。

另见:

于 2012-07-02T04:44:36.093 回答