简体   繁体   中英

How Do I Request an HTML View from a Controller in Java and not through a Web Browser using Spring MVC?

I am using Spring MVC.

In Controller1 I return a ModelAndView of the current progress of an item that is being 'published'. I am using Velocity as my view resolver if that makes any difference. What is returned, is obviously, HTML.

What I want is Controller2 and Controller3 to make a call to Controller1 and include the HTML view that Controller1 returns along with the HTML view that they will return.

I only know how to call controllers through the web browser using a URL. How do I call and receive HTML in java code?

If I can stick with just using the spring framework, that would be best.

I was reading about Spring's RestController, but I am unsure if I can return a ModelAndView using a view resolver?

Thanks.

Spring's RestTemplate is what I was looking for:

http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/client/RestTemplate.html

Here is a link where it is used used. Interesting part near the bottom:

http://dyutiman.wordpress.com/2010/12/09/simple-rest-web-service-spring/

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