Suppose there is an index.html , it is called using the controller:
@RequestMapping(value = "/index", method = RequestMethod.GET) public ModelAndView getIndex() { ModelAndView mav = new ModelAndView(); mav.setViewName("index"); return mav; } After downloading this page, let's say I have a button there when I click on it, the method is called:
<script type="text/javascript"> function getPage() { $.ajax({ type: "GET", url: "getPage", success: function (data) { $("#pageContainer").html(data); } }); } </script> Next, the Ajax request calls another controller of mine:
@RequestMapping(value = "/getPage", method = RequestMethod.GET) public ModelAndView getPage() { ModelAndView mav = new ModelAndView(); mav.setViewName("test/page"); return mav; } But the getPage () controller returns the whole html / jsp document in data. How can I rewrite the getPage () controller so that it does not return the entire page file but the necessary part of it?