我的web.xml中有一個安全約束,因此「restrict」文件夾內的所有頁面都受到保護,用戶無法手動輸入它們。將參數發送到受限制的頁面(無GET方法)
的web.xml
<security-constraint>
<display-name>restrict</display-name>
<web-resource-collection>
<web-resource-name>Restric Access</web-resource-name>
<url-pattern>/restrict/*</url-pattern>
<http-method>DELETE</http-method>
<http-method>PUT</http-method>
<http-method>HEAD</http-method>
<http-method>OPTIONS</http-method>
<http-method>TRACE</http-method>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint />
</security-constraint>
在這些頁面中的一個,我想傳遞參數給使用下面的導航規則的其他頁面。
faces-config.xml中
<navigation-rule>
<from-view-id>/restrict/ranking.xhtml</from-view-id>
<navigation-case>
<from-outcome>editPerson</from-outcome>
<to-view-id>/restrict/person.xhtml</to-view-id>
<redirect include-view-params="true">
<view-param>
<name>idPerson</name>
<value>#{ranking.person.idPerson}</value>
</view-param>
</redirect>
</navigation-case>
</navigation-rule>
但是這是不可能的,因爲我限制了GET方法,而我得到"Access to the requested resource has been denied"
。 那麼,將參數傳遞給其他頁面的正確方法是什麼?
使用@SessionScoped @ManagedBean來設置一個會話變量,並重新設置它,只要我在其他頁面中使用?
使用FacesContext.getCurrentInstance()。getExternalContext()。getSessionMap()在我使用它們時立即添加和刪除屬性?
還是什麼?
我很擔心前兩個建議,因爲用戶可能會在瀏覽器中打開很多選項卡來使用我的應用程序,所以對於所有選項卡只有一個值。
編輯:關於我得到的錯誤,還有在控制檯沒有堆棧跟蹤我正在重定向到的頁面是這樣的:
HTTP Status 403 - Access to the requested resource has been denied
type Status report
message Access to the requested resource has been denied
description Access to the specified resource has been forbidden.
Apache Tomcat/7.0.47
爲了解決這個錯誤,我可以簡單地刪除我的安全約束中的<http-method>GET</http-method>
,但我可以手動輸入頁面。
是誰提出這個例外?你能發佈你的堆棧跟蹤的相關位嗎? –
看到我編輯的問題Harsha。謝謝。 – qxlab
爲什麼你需要''?如果你不希望資源是冪等的,就省略它。如果您只是基於位於'/ WEB-INF'中的模板/包含已經不可公開訪問的情況下將結果有條件地呈現在相同視圖中,那麼整個安全約束也沒有多大意義。 –
BalusC