问题
I've defined the # of logical views and views in session attributes in web.xml to 1, so that there is only a maximum of 1 view. Given that, I've a couple of questions:
Is this # specific to a given user? Meaning, does this limit the # of views to 1 per user? ** If yes, could there be multiple view representations of the same JSP across multiple users?
Is there a way to share the JSF view across users (given that the view is rather generic and does not contain any user specific data)?
Thanks!
回答1:
If your generic definition of "an user" actually equals to "a HTTP session", then yes, you're right. Views are basically stored in the HTTP session and referenced by a hidden HTML input field with the name javax.faces.ViewState
. Different HTTP sessions will not share their views with each other, that would otherwise obviously have been a huge bug and security hole.
With setting the number of (logical) views in session to 1
, you're however removing the possibility that the user can use multiple views containing POST forms in different windows/tabs in the same session. Everytime the enduser opens a new window/tab, the enduser will receive a ViewExpiredException
whenever the enduser fires a POST request in a previous window/tab, because you've configured it to keep only one view in the session, which is the last opened one.
来源:https://stackoverflow.com/questions/6915055/are-jsf-views-shared-between-users