开发者

Java Facelets and session?

How can I use session for facelets ?

What's the syntax...?

I would put a code like this

<% String loginSession = (String)session.getAttribute("login"); %> 
<% i开发者_开发知识库f(loginSession != null){ %> 
    Welcome <%= session.getAttribute("firstName") %> ! 
<% }else{ %> 
    Guest 
<% } %>

Thanks


#{sessionScope.login}

You can't have if-s in JSF (you can with JSTL, but it has complications). Instead you can choose to render or not a component:

<h:outputText value="Guest" rendered="#{sessionScope.login != null}" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜