[英]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. 我正在使用Spring MVC。
In Controller1
I return a ModelAndView
of the current progress of an item that is being 'published'. 在
Controller1
我返回正在“发布”的项目的当前进度的ModelAndView
。 I am using Velocity as my view resolver if that makes any difference. 如果有任何区别,我正在使用Velocity作为我的视图解析器。 What is returned, is obviously, HTML.
很明显,返回的是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. 我想要的是
Controller2
和Controller3
调用Controller1
并包括Controller1
返回的HTML视图以及它们将返回的HTML视图。
I only know how to call controllers through the web browser using a URL. 我只知道如何使用URL通过Web浏览器调用控制器。 How do I call and receive HTML in java code?
如何用Java代码调用和接收HTML?
If I can stick with just using the spring framework, that would be best. 如果我坚持使用spring框架,那将是最好的。
I was reading about Spring's RestController, but I am unsure if I can return a ModelAndView using a view resolver? 我正在阅读有关Spring的RestController的信息,但不确定是否可以使用视图解析器返回ModelAndView?
Thanks. 谢谢。
Spring's RestTemplate is what I was looking for: 我一直在寻找Spring的RestTemplate:
http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/client/RestTemplate.html 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/ http://dyutiman.wordpress.com/2010/12/09/simple-rest-web-service-spring/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.