I have to return a list of employees from a controller in response to jQuery AJAX request. How should I do for it?
My controller:
@RequestMapping(value = "phcheck", produces = "application/json")
@ResponseBody
public ModelAndView pay(@RequestParam("empid") int empid, @RequestParam("fdate") String fdate, @RequestParam("tdate") String tdate) {
return entityManager.createQuery("select e from Employee e where e.empId="+empid, Employee.class).getResultList();
}
url:"phcheck.htm?empid="+$("#empid").val()+"&fdate="+$("#fdate").val()+"&tdate="+$("#tdate").val()
In Spring MVC you will have to have registered MappingJackson2HttpMessageConverter like being done here