转自:http://blog.csdn.net/chenlu123456789/article/details/9719705
1、添加jackson-all-1.6.4.jar包
2、在applicationContext.xml配制文件中添加如下代码
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list >
<ref bean="mappingJacksonHttpMessageConverter" />
</list>
</property>
</bean>
<bean id="mappingJacksonHttpMessageConverter"
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
3、在controller中添加如下代码
@RequestMapping(value="/chinese/listTree", method = RequestMethod.POST)
public @ResponseBody List getlistChinese(Model model){
List<User> list = (List<ChineseCategory>) commonMgr.find("from User");
return list;
}
返回值可以为list也可以为Map类型
1、添加jackson-all-1.6.4.jar包
2、在applicationContext.xml配制文件中添加如下代码
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list >
<ref bean="mappingJacksonHttpMessageConverter" />
</list>
</property>
</bean>
<bean id="mappingJacksonHttpMessageConverter"
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
3、在controller中添加如下代码
@RequestMapping(value="/chinese/listTree", method = RequestMethod.POST)
public @ResponseBody List getlistChinese(Model model){
List<User> list = (List<ChineseCategory>) commonMgr.find("from User");
return list;
}
返回值可以为list也可以为Map类型