why jsp fires a PropertyNotFound?

青春壹個敷衍的年華 提交于 2019-12-10 15:58:38

问题


Writing in a JSP:

${a.b.c} 

throws 'c' PropertyNotFound, but writing

<s:property value="#a.b.c"/> 

works fine.

I'd appreciate if someone can explain why ${a.b.c} doesn't work?

UPDATED:

In the same JSP, accessing to another bean f such as ${a.f.d} it finds d correctly.

I have checked that property c in ${a.b.c} exists.


回答1:


Nice Question.If you have not specified getter setters for property c in b then this error will occur Propertynotfound for

 ${a.b.c}

But

  <s:property value="#a.b.c"/> 

will not cause an error. The difference is ${} works on getter setters as it is OGNL it reads using getter setter from valuestack.

Simply write getter setter in class b. ${a.b.c} will start working. For example if c is public String c then,

public String getC() {
    return c;
}
public void setC(String c) {
    this.c = c;
}


来源:https://stackoverflow.com/questions/21874470/why-jsp-fires-a-propertynotfound

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!