The problem occurs:
Return via @Responsebody
@ResponseBody@RequestMapping(value ="/selectByFormId",method = RequestMethod.GET)public Map<String,Object> getClassName(String formId){ List<String> list =formInfoService.selectClassName(formId); Map<String,Object> map = new HashMap<String, Object>(); map.put("data", list); map.put("status", true); return map;}result:
{"data":["Bixuan Crazy Silhouette","Qi Ling","Silhouette","Silhouette","Bi Hair Shape","Bi Hair Shape","Chen Huan Lan Shape",<br>"Silhouette","Han Hong Lan Shape","Lu ㈡ ㈡ ㈣ Ling","Han Hong Lan Shape","Salute":true}Solution:
Configure in spring-mvc.xml
<!-- Solve the ResponseBody garbled problem. StringHttpMessageConverter. When converting the converter of the parent class AbstractHttpMessageConverter, the supportedMediaTypes property of the parent class AbstractHttpMessageConverter iso-8895-1 by default, it is caused by --> <mvc:annotation-driven> <mvc:message-converters> <bean> <property name="supportedMediaTypes" value="text/html;charset=utf-8"></property> </bean> </mvc:message-converters> </mvc:annotation-driven>
But after the configuration, there are new problems
error:...cvc-complex-type.2.1: The element 'mvc:annotation-driven' must contain no characters or element information item [child], because the content type of the type is empty.
Later I found out that the XSD file version of springMVC is wrong, so I can just change it to springMVC 4.0 XSD
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd">
Then it's OK
{"data":["Information Request", "Promotional", "Management", "Temporary Branch", "Storage and Transportation", "Assets", "Information Service", "Travel Management", "Procurement", "Personnel Attendance"<br>, "Financial", "Customer", "Visiting Proposal", "Customer Complaints", "Personnel Activity", "Personnel Administrative", "Official Documents", "Payment Management", "Operation Business"], "status":true}StringHttpMessageConverter This method has many conversion functions, so you can take a look at it if you have time.
The solution to the above article spring+mybatis to return the results through @ResponseBody is the entire content shared by the editor. I hope it can give you a reference and I hope you will support Wulin.com more.