[英]How to pass data to browser javascript from Spring MVC controller
I would like to pass data from Spring MVC to javascript but I am not sure what is the best way to do it. 我想将数据从Spring MVC传递到javascript,但是我不确定什么是最好的方法。
Say, in javascript, there an array 说,在javascript中,有一个数组
var myArray = new Array();
In backend java, there is an array 在后端Java中,有一个数组
int[] myArray = new int[100];
What is the best way to pass this array to the front end javascript. 将此数组传递给前端javascript的最佳方法是什么。 What about multiple arrays as well?
那么多个数组呢?
Thanks! 谢谢!
You'll want to json-ify your array. 您将要对数组进行json-ify。 Best way is to have your view use the built in MappingJacksonHttpMessageConverter.
最好的方法是让视图使用内置的MappingJacksonHttpMessageConverter。
Might want to look at this thread: 可能想看一下这个线程:
How to configure MappingJacksonHttpMessageConverter while using spring annotation-based configuration? 在使用基于Spring注释的配置时如何配置MappingJacksonHttpMessageConverter?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.