1

我必须根据用户角色 outputText 框在 JSF 中呈现 outputText:

<h:outputText id="citizenaddress" value="#{customerView.customerCurrentAddress}" escape="false" rendered="#{facesContext.externalContext.userInRole('isabletoGetCitizenAddress')}"></h:outputText>

web.xml 是:

<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

例外是:

javax.el.ELException: /info/citizenInfo.xhtml @42,193 rendered="#{facesContext.externalContext.userInRole('isabletoGetCitizenAddress')}": Method userInRole not found
4

2 回答 2

1

该方法是isUserInRole(String)

您可能会将 bean 属性的表达式规则与方法的语法混为一谈。

我认为表达式应该是:

#{facesContext.externalContext.isUserInRole('isabletoGetCitizenAddress')}
于 2013-01-10T12:29:04.923 回答
0

尝试将双引号更改为isabletoGetCitizenAddress单引号。 <h:outputText id="citizenaddress" value="#{customerView.customerCurrentAddress}" escape="false" rendered="#{facesContext.externalContext.userInRole('isabletoGetCitizenAddress')}"></h:outputText>

于 2013-01-10T12:23:19.813 回答