How to access Spring MVC model object in javascript file?

前端 未结 8 1136
南方客
南方客 2020-12-28 19:05

I am using spring 3 MVC and i have below classes.

External system would call my application using below URL:

http://somehost/root/param1/param2/param         


        
8条回答
  •  伪装坚强ぢ
    2020-12-28 19:29

    I recently faced the same need. So I tried Aurand's way but it seems the code is missing ${}. So the code inside SomeJsp.jsp is:

    
    

    Note that you can't asssign using var model = ${model} as it will assign a java object reference. So to access this in external JS:

    $(document).ready(function() {
       alert(model.paramOne);
    });
    

提交回复
热议问题