简体   繁体   English

如何使用Spring MVC从Java中的控制器而不是通过Web浏览器请求HTML视图?

[英]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. 我想要的是Controller2Controller3调用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. 谢谢。

暂无
暂无

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

相关问题 我如何将原始HTML从Java Spring Controller传递到JSP视图 - How do i pass raw HTML from java spring controller to jsp view 如何通过Spring MVC中的Controller将数据从MongoDB转换为View - How to convert the data from MongoDB to the View through the Controller in Spring MVC 如何在Spring MVC中使用Controller和Request Mapping修复“找不到” html? - How to fix “Not Found” html using Controller and Request Mapping in Spring MVC? 如何生成从HTML页面到Spring MVC控制器的下载请求 - How to generate a download request from html page to controller of spring mvc 如何像使用HttpServletRequest一样从Spring MVC中的org.springframework.web.context.request.WebRequest中获取requestUrl? - How can I get the requestUrl from org.springframework.web.context.request.WebRequest in Spring MVC like we do using HttpServletRequest? 通过Spring MVC Controller动作,如何获得对请求/响应的访问? - From a spring mvc controller action, how do I get access to request/response? 如何将对象从控制器发送到视图Spring MVC - How can I send an object from a controller to a view Spring MVC 如何在Java / Spring Web MVC中设置全局变量? - how do I set global variables in Java/Spring web MVC? 使用Spring Web MVC的ModelAndView返回相同的视图控制器 - Return same view controller using ModelAndView of Spring Web MVC Spring Web MVC:如何在视图类而不是控制器中使用ResponseEntity? - Spring Web MVC: How to use a ResponseEntity in the view class, not the controller?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM