Search code examples
javaspringspring-mvcspring-roo

Spring Roo: How to get the attributes of the model passed to the view


I have created a project using Spring Roo. I have a User entity (MODEL), which I pass to a .jspx file (VIEW). I would like to display the User information such as name, address and other attributes that my User class has.

This is the code in the controller that passes the Model to the View:

@RequestMapping(value = "/{id}", produces = "text/html")
public String UserRoleController.show(@PathVariable("id") Long id, Model uiModel) {
    uiModel.addAttribute("userrole", UserRole.findUserRole(id));
    return "userroles/account";
}

I know that in a jspx file I can get the information passed by using ${"userrole"}, but how do I get the actual attributes of the object?


Solution

  • Very simple, in your JSP just do :

    ${userrole.yourAttribute}
    

    No need to use quotes or whatever when you are inside a ${}.