How to get spring mvc controller model key value inside javascript?

前端 未结 3 2064
忘了有多久
忘了有多久 2021-01-12 03:12

I am using a spring mvc controller. Inside controller i am putting some value lets say string inside model. Now i would like to retrive that value or lets just say print tha

3条回答
  •  灰色年华
    2021-01-12 04:12

    Try this...

    If you had added the object into the model as:

    model.addAttribute("someObject", new Login("uname","pass"))
    

    Then you get the properties of the model object as

    var user_name = ${someObject.uname}; // This is assuming that the Login class has getter as getUname();
    var user_pass = ${someObject.pass};
    

提交回复
热议问题