我有两个类:
可以说
class ABC{
private String a,b;
public void setA(String a){
this.a = a;
}
public void setB(String b){
this.b = b;
}
public String getA(){
return this.a;
}
public String getB(){
return this.b ;
}
}
class XYZ{
private ABC abc;
public void setABC(ABC abc){
this.abc = abc;
}
public ABC getABC(){
return this.abc;
}
}
类 XYZ 具有类 ABC 属性。
我想在 JSTL 的帮助下访问 JSP 页面之一中的 ABC 类属性 a 或 b
以这种方式
${XYZ.ABC.A}
最佳答案
要在JSP中引用bean,需要将对象放入request中。
request.setAttribute("xyz", xyz);
然后通过 JSP 中的 ${xyz.abc.a}
访问它。
关于java - 在 JSP 页面上访问 JSTL 中的嵌套对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14706019/