I am using spring 3.2 and I have come with one requirement and can't figure out how to achieve it, first please look for below
- We mostly use model in Spring MVC which is use for data binding
- @ResponseBody annotation returns the string as http response
So my requirement is I want to use both together in single method base on condition, Here is my code
@RequestMapping(value="userAddEditSubmit.htm", method={RequestMethod.GET, RequestMethod.POST}) public String userAddEditSubmit( @ModelAttribute("user") User user, HttpServletRequest request, HttpServletResponse response, HttpSession session, Model model ) throws Exception { try { //Here is my logic return "redirect:" + url; } catch (Exception e) { e.printStackTrace(); throw e; } } So above is my method which returns specific jsp with model attribute, but now in one condition I have requirement to return String data instead of whole jsp in the same method, what can I do to achieve this? Any help will be highly appreciated.