JSF渲染不';行不通
我正在使用JSF开发一个应用程序。我想当用户登录到页面时,显示一条消息说“你好”。每次用户使用其凭据正确登录时,用户id都存储在currentUser属性中 如果用户未登录并访问我的页面,请在浏览器中写入URL(没有用户id),以显示一条消息,说明“您没有访问此页面的权限”。我做错了什么? 这是显示消息的代码JSF渲染不';行不通,jsf,Jsf,我正在使用JSF开发一个应用程序。我想当用户登录到页面时,显示一条消息说“你好”。每次用户使用其凭据正确登录时,用户id都存储在currentUser属性中 如果用户未登录并访问我的页面,请在浏览器中写入URL(没有用户id),以显示一条消息,说明“您没有访问此页面的权限”。我做错了什么? 这是显示消息的代码 <h:form rendered="#{usersManagedBean.currentUser ne null}"> <h:outputText value=
<h:form rendered="#{usersManagedBean.currentUser ne null}">
<h:outputText value=" hello " />
</h:form>
<h:form rendered="#{usersManagedBean.currentUser eq null}">
<h:outputText value="You have no rigths to access this page" />
</h:form>
改用空运算符
<h:form rendered="#{not empty usersManagedBean.currentUser}">
<h:outputText value=" hello " />
</h:form>
<h:form rendered="#{empty usersManagedBean.currentUser}">
<h:outputText value="You have no rigths to access this page" />
</h:form>
在中找到空运算符
1.10空操作员-空A
空运算符是前缀运算符,可用于确定值是null还是空。
计算空值
如果A为null,则返回true
否则,如果A是空字符串,则返回true
否则,如果A是空数组,则返回true
否则,如果A是空映射,则返回true
否则,如果是空集合,则返回true
否则返回false
#{not empty usersManagedBean.currentUser}
对应于not null
和!=''代码>。尝试执行此操作,并检查是否根据不同用户的操作在关联的支持bean中正确设置了usersManagedBean.currentUser
。将呈现哪种输出?
1.10 Empty Operator - empty A
The empty operator is a prefix operator that can be used to determine if a value is null or empty.
To evaluate empty A
If A is null, return true
Otherwise, if A is the empty string, then return true
Otherwise, if A is an empty array, then return true
Otherwise, if A is an empty Map, return true
Otherwise, if A is an empty Collection, return true
Otherwise return false