小编meh*_*alp的帖子

如何在 xHtml 的 IF-Else 语句中插入 HTML 代码?

我的页面上有primefaces 数据表

我在我的专栏上显示了两个数字。

我是这样的:

 #{pushNotification.status==1? 'FINISHED' : 'STOP'}
 *// If the data == 1 show 'FINISHED' else show 'STOP'*
Run Code Online (Sandbox Code Playgroud)

但我想在 if 语句中运行 HTML 代码,而不仅仅是文本。

我试过这样;

 #{pushNotification.status==1? '<a>FINISHED</a>' : 'STOP'}
Run Code Online (Sandbox Code Playgroud)

给了我“ EL 表达式”错误;

javax.el.ELException: EL Expression Unbalanced: ... #{pushNotification.status==1? '' : 'STOP' '
at com.sun.faces.facelets.el.ELText.findVarLength(ELText.java:428)
at com.sun.faces.facelets.el.ELText.parse(ELText.java:373)
at com.sun.faces.facelets.el.ELText.parse(ELText.java:325)
at com.sun.faces.facelets.compiler.TextUnit.flushTextBuffer(TextUnit.java:139)
at com.sun.faces.facelets.compiler.TextUnit.addInstruction(TextUnit.java:127)
at com.sun.faces.facelets.compiler.TextUnit.startTag(TextUnit.java:197)
at com.sun.faces.facelets.compiler.CompilationManager.pushTag(CompilationManager.java:313)
at com.sun.faces.facelets.compiler.SAXCompiler$CompilationHandler.startElement(SAXCompiler.java:247)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
Run Code Online (Sandbox Code Playgroud)

java jsf if-statement primefaces

2
推荐指数
1
解决办法
6112
查看次数

标签 统计

if-statement ×1

java ×1

jsf ×1

primefaces ×1