The problem occurs:
Return via @Responsebody
@ResponseBody @RequestMapping(value ="/selectByFormId",method = ) public Map<String,Object> getClassName(String formId){ List<String> list =(formId); Map<String,Object> map = new HashMap<String, Object>(); ("data", list); ("status", true); return map; }
result:
{"data":["Bi'er's swelling in a crazy way","Qi'an's silk","Plant","Shadowed silk","Oral supplies","Bi Xie Yan","Bi'er's Account Award","ChenNo power"electricity ",<br>"Snacking and panting","Hambola's key to the silhouette","Lu ㈠Guangke","Kakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakakaka","Naoyaoyaoyaoyao","�㈣South","Hanboo, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa, wa,,"Hamboo Shi Chen and Yu Ling","AssociateKing of Wild�",<br>"Xuanfengking�","Closed € pot $","All Bobo Bobo Bobo Bobo Bobo"],"status":true}
Solution:
Configure in
<!-- solveResponseBody Garbage code problemStringHttpMessageConverterWhen this converter is converted,Parent classAbstractHttpMessageConverterofsupportedMediaTypesThe attribute default isiso-8895-1lead to --> <mvc:annotation-driven> <mvc:message-converters> <bean class=""> <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: element 'mvc:annotation-driven' 必须不含字符或element信息项 [Sub-level], Because the content type of this type is empty。
Later I found out that the XSD file version of springMVC is wrong, so I just need to change it to springMVC 4.0 XSD
<beans xmlns="/schema/beans" xmlns:xsi="http:///2001/XMLSchema-instance" xmlns:p="/schema/p" xmlns:context="/schema/context" xmlns:mvc="/schema/mvc" xsi:schemaLocation="/schema/beans /schema/beans/spring-beans-3. /schema/context /schema/context/spring-context-3. /schema/mvc /schema/mvc/spring-mvc-4.">
Then it's OK
{"data":["Information Request","Promotional","Management Class","Temporary Branch Class","Storage and Transportation","Assets","Information Services","Travel Management","Procurement","Personnel Attendance"<br>,"Financial","Customer","Visit-Top","Customer complaint","Personnel Activities","Personnel and Administration","Official Documents","Application Class","Sales and Management","Operational Business"],"status":true}
StringHttpMessageConverter This method It has many conversions,You can take a look 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 support me more.