我的春天mvc控制器:
@RequestMapping(value="/company/{companyname}")
public String getUserName(Model model,@PathVariable("companyname") String companyname){
System.out.println(companyname);
Registration orgInfo=userservice.orgByname(companyname);
System.out.println("uname:"+orgInfo.getLoginCredentials().getUserName());
model.addAttribute("orgInfo",orgInfo);
return "orgProfile";
}
我想在jsp文件中打印用户名;我试着用这种方式:
${orgInfo.LoginCredentials.UserName}
但它说
javax.el.PropertyNotFoundException: Property 'LoginCredentials' not found on type orgProfiles.model.Registration
但在我的控制器中,我可以像这样打印:
System.out.println("uname:"+orgInfo.getLoginCredentials().getUserName());
orgByname(companyname)的hibernate查询;是:
Hibernate:
select
registrati0_.id as id0_,
registrati0_.address as address0_,
registrati0_.description as descript3_0_,
registrati0_.latitude as latitude0_,
registrati0_.longitude as longitude0_,
registrati0_.name as name0_,
registrati0_.place as place0_,
registrati0_.type as type0_,
registrati0_.website as website0_
from
Registration registrati0_
where
registrati0_.name=?
Hibernate:
select
logincrede0_.logind as logind1_0_,
logincrede0_.password as password1_0_,
logincrede0_.userName as userName1_0_
from
LoginCredentials logincrede0_
where
logincrede0_.logind=?
unameabc@gmail.com
如何从jsp文件访问该对象?
答案 0 :(得分:1)
在JSP中,您需要通过属性表示法访问getter:
${orgInfo.loginCredentials.userName}
(注意小写的初始化!)