简体   繁体   中英

How to consume ModelAndView Response from spring MVC in Angular 6?

I am working on a project where I have to consume the response returned by spring MVC controller ( return type of controller is ModelAndView ) and show that as UI. I know how to consume JSON response in Angular but I don't know how to deal in this case.

If you are using $http it means you are making a Ajax call.

You don't get a ModelAndView object in AJAX, since it just sees the response from the request and what it will see is HTML.

If you want to get just the data don't use ModelAndView , I suggest you make another controller method just returning the object you want with a @ResponseBody annotation.

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