Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
给定一个类A:
A
public class A { private String foo; //getter, setters etc... }
foo如果A对象本身作为托管 bean 中的属性公开,则可以引用该属性,例如:
foo
@ManagedBean public class SomeBean { private A a; //getter, setters etc... }
#{someBean.a.foo}
确实,它会起作用。用于设置和获取值。输入,例如:
<h:inputText value="#{someBean.a.foo}" />
将获得显示它的值并通过执行以下任一操作设置新定义的值
beanInstance.getA().getFoo();
或者
beanInstance.getA().setFoo("newValue");
只需考虑到要使其正常工作并避免获得NullPointerException, getA()cannot return null,这意味着您的a对象必须被实例化。
NullPointerException
getA()
null
a