【发布时间】:2012-09-01 08:52:25
【问题描述】:
有人对我如何解决此警告有任何创意吗?
EL 语法错误:表达式不能以二元运算符开头
由以下代码引起:
String.format("#{myController.deleteItemById(%d)}", getId())
我的代码以前是这样的:
"#{myController.deleteItemById(" + getId() + ")}"
但这会导致 eclipse 产生以下警告:
EL 语法错误:字符串未关闭
更新:
@ManagedBean(name = "myController")
@ViewScoped
public class MyController implements Serializable {
private long id;
private HtmlPanelGroup panel;
public long getId() {return this.id; }
private void getPanel() {
/// bunch of code for programatically creating a form
HtmlCommandButton deleteButton = new HtmlCommandButton();
deleteButton.setId(id);
deleteButton.setValue(value);
deleteButton.setActionExpression(/* EL expression used here */);
}
}
<?xml version='1.0' encoding='UTF-8' ?>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<!-- some other elements removed for the sake of clarity -->
<h:body>
<h:panelGroup binding="#{myController.panel}" />
</h:body>
</html>
【问题讨论】:
-
你是使用任何框架jsf还是只使用jstl\
-
如何/何时评估 el 表达式?你把它包含在一个jsp页面中还是其他的?
-
或者你只得到一个 Eclipse 警告并且在运行时表达式计算正确?
-
还是不清楚。您收到 Eclipse 警告或 runtime 错误?
-
@dcernahoschi 日食警告