【发布时间】:2011-09-08 15:15:21
【问题描述】:
公共类客户{
私人用户用户;
私有字符串名称;
公共用户 getUser() {
返回用户;
}
公共无效setUser(用户用户){
this.user = 用户;
}
公共字符串 getName() {
返回名称;
}
公共无效集合名称(字符串名称){
this.name = 名称;
}
}
公共类用户{
私有字符串名称;
公共字符串 getName() {
返回名称;
}
公共无效集合名称(字符串名称){
this.name = 名称;
}
}
公共静态无效主要(字符串[]参数){
尝试 {
客户客户=新客户();
对象树 = Ognl.parseExpression("user.name");
Ognl.setValue(树,客户,“你好”);
} 捕捉(OgnlException e){
e.printStackTrace();
}
}
ognl.OgnlException: setProperty(null, "name", hello) 的目标为空
如何让ognl自动创建用户。
【问题讨论】: