Overcoming them is what makes life meaningful I am enjoying Challenges
Wednesday, 8 July 2015
Spring rest json responce
1) Create bean of JSON view resolver
<bean name="jsonTemplate" class="org.springframework.web.servlet.view.json.MappingJackson2JsonView"/>
2) Return this Json view from modelAndView controller
@RequestMapping(value = "/clients")
public String getAllClientsJSON(Model model) {
model.addAttribute("clients", getClientsCollection());
return "jsonTemplate";
}
//getClientsCollection() this meothod will have list of clients
<bean name="jsonTemplate" class="org.springframework.web.servlet.view.json.MappingJackson2JsonView"/>
2) Return this Json view from modelAndView controller
@RequestMapping(value = "/clients")
public String getAllClientsJSON(Model model) {
model.addAttribute("clients", getClientsCollection());
return "jsonTemplate";
}
//getClientsCollection() this meothod will have list of clients
Subscribe to:
Posts (Atom)