最近因为修改Spring事务的原因,修改了SpringMVC的配置文件,可是最后发现使用AJAX获取后台数据是出现乱码问题。最后发现是因为SpringMVC配置文件中新增了个标签:
引起的,因为之前在配置文件有这样的配置:
text/plain;charset=UTF-8
如果增加上标签,则这个配置将会失效。由于着急,没有跟源码,直接问度娘,有网友说加上如此代码问题可以解决:
application/json;charset=UTF-8
这个时候编辑器报错,说annotaion-driver标签里不能包含子元素。我去,网友怎么呢蒙人呢,后来发现是因为XSD文件版本低了,于是我换成了3.2版本的,问题解决。修改XSD引入代码如:
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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util"
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.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">
如果你是其他版本也可以换成其他版本,地址在:http://www.springframework.org/schema/mvc/
所以每种问题的解决都受其环境局限,没有什么技术含量,记下来万一能帮上其他网友呢。