0

I'm pretty new to JSTL so bear with me. I have a class I created that I'm try to access properties from in JSTL. I can't figure out what I'm doing wrong here. I'm not getting an error I"m just getting nothing when I try to call "getChildPath" Is it something in the java class that I'm doing that I'm not able to access it in the JSTL? Any help is greatly appreciated.

Java Class:

public class childPath{

private String childPath = ""; 

public childPath(Resource resource) throws RepositoryException{     
    ValueMap properties = resource.adaptTo(ValueMap.class);     
    childPath = properties.get("childPath", "");                    
}       
public String getChildPath() {
    return childPath;
}  

My JSTL Reference:

${getChildPath}
4

1 回答 1

0

首先,您应该修复您的命名以遵循 java 命名约定。

比如说,您已将一个 javabean (type childPath) 实例 (named bean) 传递给您的 jsp,在您的 jsp 中您可以private String childPath通过以下方式引用该属性:

${bean.childPath}

使用属性/属性名称而不是方法(getter)名称。

于 2013-04-19T23:20:33.103 回答