使用参数 JSP 调用函数
Call function with parameter JSP
编辑:交换 ${h.helloWorldName('Audren')}
与 ${h.getHelloWorldName('Audren')}
我有一个测试class :
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'}
您只是少了一个括号(并删除了 '')。
正确语法:
"${h.helloWorldName(Audren)}"
编辑:交换 ${h.helloWorldName('Audren')}
与 ${h.getHelloWorldName('Audren')}
我有一个测试class :
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'}
您只是少了一个括号(并删除了 '')。 正确语法:
"${h.helloWorldName(Audren)}"