我正在使用 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 (.post()) 函数调用控制器.
What I actually have is a Controller that returns a String. I call the Controller using JQuery (.post()) function.
我的解决方案的问题是我无法像使用 ModelAndView 作为返回类型时那样呈现 JSP.
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?
提前致谢.
纽基诺
推荐答案你可以把这个页面放到一个单独的 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 渲染视图
发布评论