简体   繁体   中英

What is the type of data which, is sent by `model.addAttribute` from controller to JSP

I'm new to Spring boot please help me.I am trying to send a list of objects(rooms) from controller by model.addAttribute to JSP ; Firstly ,I don't understand what is the type of data that JSP is recieving? I mean is it a text file?(if yes ,is it JSON?), is it a list of objects as I sent from controller? Secondly, I want to print out this list in consul or in HTML ,how can I do that ? I know, with jstl foreach and by using ${rooms} I can do that, but how can I access elements of list, in Javascript and print with Javascript? Finally,is it possible to change some elemnts of this list in Javascript and then return it to controller and how?

JSP is not same as HTML. It first gets executed in the same JVM as your controller with same "instances" of objects that are put into model.addAttribute . Then it gets converted to HTML and is written back to the browser via HttpServletResponse .

The Javascript is only executed on the borwser and wont have access to those objects any more. It can only access to whatever is written into the HTML.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM