Get Request and Session Parameters and Attributes

2020-01-26 03:22发布

I'm using JSF with facelets and I need to get the request and session parameters inside the JSF page. In JSP pages I got this parameter like that: "${requestScope.paramName}" or "${sessionScope.paramName}". But now after using JSF there are only beans and you can't get any value except bean attributes.

NOTE: The session attributes what I need is auto filled using acegi security so I can't get any access to them.

So what to do now?

8条回答
手持菜刀,她持情操
2楼-- · 2020-01-26 04:21

Assuming that you already put your object as attribute on the session map of the current instance of the FacesContext from your managed-bean, you can get it from the JSF page by :

<h:outputText value="#{sessionScope['yourObject'] }" />

If your object has a property, get it by:

<h:ouputText value="#{sessionScope['yourObject'].anyProperty }" />
查看更多
家丑人穷心不美
3楼-- · 2020-01-26 04:22

You can also use a tool like OcpSoft's PrettyFaces to inject dynamic parameter values directly into JSF Beans.

查看更多
登录 后发表回答