instanceof check in EL expression language
问题 Is there a way to perform an instanceof check in EL? E.g. <h:link rendered="#{model instanceof ClassA}"> #{errorMessage1} </h:link> <h:link rendered="#{model instanceof ClassB}"> #{errorMessage2} </h:link> 回答1: You could compare Class#getName() or, maybe better, Class#getSimpleName() to a String . <h:link rendered="#{model['class'].simpleName eq 'ClassA'}"> #{errorMessage1} </h:link> <h:link rendered="#{model['class'].simpleName eq 'ClassB'}"> #{errorMessage2} </h:link> Note the importance of