「Spring」@ResponseBodyでjsonデータを返却するコード

Javaコード
@ResponseBody
@RequestMapping(“/list")
public List<String> list(ModelMap modelMap) {
String hql = “select c from Employee c “;
Page<Employee> pg = new Page<Employee>();
pg.setPageSize(6);
pg= employeeServiceImpl.queryForPageByHql(pg, hql);

return pg.getResult();
}

mvc-servlet.xml
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"
p:ignoreDefaultModelOnRedirect="true" >
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"/>
</list>
</property>
</bean>

Java

Posted by arkgame