gpt4 book ai didi

java - EL语法错误: Expression cannot start with binary operator

转载 作者:行者123 更新时间:2023-11-30 04:41:19 27 4
gpt4 key购买 nike

有人对如何解决此警告有任何创意吗?

EL syntax error: Expression cannot start with binary operator

由以下代码引起:

String.format("#{myController.deleteItemById(%d)}", getId())

我的代码以前看起来像这样:

"#{myController.deleteItemById(" + getId() + ")}"

但这导致 eclipse 生成以下警告:

EL syntax error: String is not closed

更新:

@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>

最佳答案

您可以使用 @SupressWarnings("el-syntax") 对该方法进行注释,Eclipse 将不再烦扰您。它会要求抑制未知的(对于 Java 框架)抑制警告等。如果您不让它抑制,它会向注释添加警告。

.

但是通过在运行时构建 EL 表达式,您可以将应用程序暴露给 EL Injection .

.

有人可能通过注入(inject)方法调用等方式在您的服务器上运行恶意代码。

检查EL中间字符串的来源是否来自完全安全的来源,

sanitize your inputs来防止它。

关于java - EL语法错误: Expression cannot start with binary operator,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12226351/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com