我的 bean 看起来像这样:
@Entity
public class Fattura {
@Id
Long id;
@NotEmpty
String numero;
@Min(value=0)
Double importo;
Key<User> utente;
// gets & sets....
}
“utente”属性是我创建的另一个 bean 的键:一个“Fattura”只能有一个“User”,一个“User”可以有多个“Fattura”
我的 Spring MVC 控制器将管理对 Fattura 列表的请求,并将它们显示在一个简单的 jsp 中:
@RequestMapping( value = "/fatture" , method = RequestMethod.GET )
public ModelAndView leFatture() {
ModelAndView mav = new ModelAndView("fatture");
mav.addObject("fatture",fatturaService.listFatture());
return mav;
}
jsp的代码真的很简单:表中只有一个foreach循环
我的问题是:
我怎样才能显示“utente”?
我唯一拥有的是它的密钥,但我想在我的 JSP 中做类似${fattura.utente.firstName}的事情,我该怎么做?