2016-01-26 235 views
-1

编辑:swapp'd ${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'}

回答

1

你只是错过了括号(也删除了'')。 正确语法:

"${h.helloWorldName(Audren)}"