如何使Spring MVC中使用AJAX视图 [英] How to render a View using AJAX in Spring MVC
问题描述
我使用Spring MVC和我需要做一个异步调用服务器并刷新只有一张页面。
I'm using Spring MVC and I need to make an asynchronous call to the server and refresh only a piece of the page.
我其实已经是一个控制器,它返回一个字符串。我呼吁使用JQuery控制器(。员额())函数。
What I actually have is a Controller that returns a String. I call the Controller using JQuery (.post()) function.
我的解决方案的问题是,我不能够呈现一个JSP像我这样做,当我使用的ModelAndView作为返回类型。
The problem with my solution is that I'm not able to render a JSP like I do when I use ModelAndView as return type.
有没有办法返回已经渲染视图?
Is there any way to return a View already rendered?
在此先感谢。
Neuquino
推荐答案
您可以把这块页面到一个单独的JSP,并返回一个的ModelAndView
指向它从你的方法。有从该点AJAX和非AJAX调用没有什么区别。
You can put this piece of page into a separate JSP and return a ModelAndView
pointing to it from your method. There are no difference between AJAX and non-AJAX calls from that point.
这篇关于如何使Spring MVC中使用AJAX视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!