How to add Object in using model.addAttributes in Spring MVC

后端 未结 4 703
醉酒成梦
醉酒成梦 2021-02-06 16:56

I\'m trying to retrieve the user information from DB and display in the front end (JSP) using Spring MVC.

Inside the controller, currently I\'m adding the following cod

4条回答
  •  遇见更好的自我
    2021-02-06 16:58

    In controller add as below

        ModelMap model = new ModelMap();
        model.put("user", user);
    

    In jsp use like this

        ${user.name}
    

提交回复
热议问题