Spring mvc 了解Spring mvc生产/消费和销售
我正在运行一个带有嵌入式jetty的Spring MVC 3 maven应用程序,配置如下:Spring mvc 了解Spring mvc生产/消费和销售,spring-mvc,jackson,spring-annotations,Spring Mvc,Jackson,Spring Annotations,我正在运行一个带有嵌入式jetty的Spring MVC 3 maven应用程序,配置如下: <plugin> <groupId>org.mortbay.jetty</groupId> <artifactId>maven-jetty-plugin</artifactId> <version>6.1.14</version> <confi
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.14</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<testClassesDirectory>/Users/mydownloads/Downloads/jackson-all-1.8.10.jar</testClassesDirectory>
<useTestClasspath>true</useTestClasspath>
</configuration>
</plugin>
我在jQuery上有
数据类型:“json”
您没有正确设置请求内容类型
正如您在发布的标题中所看到的,内容类型
标题值为application/x-www-form-urlencoded
,这是jquery的默认值
在jQueryAjax调用中使用contentType:'application/json'
属性
dataType
属性告诉jquery在响应中需要什么内容类型。检查请求的内容类型是否设置为正确的值(application/json
),我在jquery端有dataType:'json'
。我还发布了请求标题。
Request URL:http://localhost:8080/myapp/postSomething
Request Method:POST
Status Code:415 Unsupported Media Type
**Request Headersview source**
Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Connection:keep-alive
Content-Length:23
Content-Type:application/x-www-form-urlencoded
Cookie:JSESSIONID=1f0mox1qw67zl
Host:localhost:8080
Origin:http://localhost:8080
Referer:http://localhost:8080/myapp/
X-Requested-With:XMLHttpRequest