简体   繁体   English

如何将从REST控制器返回的JSON对象映射到html页面

[英]How to map JSON object returned from REST controller to html page

I need to know how data returned from the Spring MVC REST controller attaches to html page and what the Spring configuration do we have to do this. 我需要知道从Spring MVC REST控制器返回的数据如何附加到html页面,以及我们必须要做的Spring配置。 The browser just prints this data out without view and that's all. 浏览器只是将这些数据打印出来而没有视图,仅此而已。 I have some Spring configurations to do it but unfortunatelly it doesn't work. 我有一些Spring配置可以执行此操作,但不幸的是它不起作用。

First, you have to create a spring web-mvc application with a correct configuration that will run without errors. 首先,您必须创建一个具有正确配置的spring web-mvc应用程序,该应用程序将正确运行。 There are plenty of tutorials on how to do it. 有很多关于如何执行此操作的教程。 After that, if you wish to get json data using your rest controllers, the most popular way to do it is by using javascript and the JQuery library. 之后,如果您希望使用rest控制器获取json数据,最流行的方式是使用javascript和JQuery库。 Using them you can make ajax calls to your api. 使用它们,您可以对您的api进行ajax调用。 There are plenty of tutorials on how to achive this again. 关于如何再次实现这一目标,有很多教程。 Finnaly, your data will be on the client side and you can manage them (render them in your html-dom etc) using javascript and JQuery again. 最终,您的数据将在客户端,您可以再次使用javascript和JQuery对其进行管理(在html-dom等中呈现它们)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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