【问题标题】:Call function with parameter JSP带参数 JSP 调用函数
【发布时间】:2016-01-26 09:48:30
【问题描述】:

编辑:将${h.helloWorldName('Audren')}${h.getHelloWorldName('Audren')} 交换

我有一个测试班:

public class classtest {

    private String helloWorld;
    private String helloWorldName;

    public String getHelloWorld(){
        return "Hello world!";
    }

    public void setHelloWorld(String s) {
        helloWorld = s;
    }

    public String getHelloWorldName(String s) {
        return getHelloWorld() + s;
    }

在我的 jsp 中,我想打印我的方法 getHelloWorldName 的结果。这是我到目前为止所尝试的:

<jsp:useBean id="h" class="com.test.classtest" scope="page" />
<c:out value="${h.helloWorldName('Audren'}" />

但没有成功。我错过了什么吗?我也试过#{h.helloWorldName('Audren'}

【问题讨论】:

    标签: java jsp el


    【解决方案1】:

    您只是缺少一个括号(并且还删除了 '')。 正确的语法:

    "${h.helloWorldName(Audren)}"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-04-02
      • 2013-02-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-13
      • 1970-01-01
      相关资源
      最近更新 更多