贴上异常
Failed to load resource: the server responded with a status of 406 ()
下面是我的WEB.XML文档
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>springMVC01</display-name>
<servlet>
<servlet-name>SpringMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- 局部变量,可向Listener,Filter,Servlet里面传参 -->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring.xml</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>SpringMVC</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
</web-app>
一开始百思不得其解,后来弄明白了.
看我配置中
因为做伪装处理所以把后缀名后改成了html
<url-pattern>*.html</url-pattern>
导致了spring mvc会默认采用text/html来编码,因此出现Json格式出现异常
总结:只要把html改成其他的就可以正?;袢son字符串了
<url-pattern>*.json</url-pattern>