415在ajax调用Spring MVC中发送JSON对象不支持的媒体类型 [英] 415 unsupported media type for sending json object in ajax call Spring mvc
问题描述
我正在将Ajax调用中的json对象发送到spring mvc控制器.
I am sending json object to spring mvc controller from ajax call.
这是我要发送给控制器的json对象.
Here is my json object which i am sending to controller.
[{"id":"7","priority":"8","startTime":"2015-09-23 01:01:00.0"}]
我的ajax呼叫
$.ajax({
url : 'save.web',
datatype:'json',
type: "post",
data: "data="+JSON.stringify(jsonArray),
success:function(data){
}
我的控制器
RequestMapping(value = "save.web", method = RequestMethod.POST)
public String save( HttpServletRequest request, HttpServletResponse
response,@RequestBody Map<String, Object> inputParameter,
@RequestParam("data") String ja) {
System.out.println("--------------Entered Save-----------");
return "menu"
}
我尝试使用@requestBody注释代替@requestParam.我尝试设置标题并在RequestMapping中使用了耗材仍然我在POST http://localhost:8089/campaignManager/save .web 415(不受支持的媒体类型) 错误.
i tried using @requestBody annotation Instead of @requestParam. I tried Setting Headers and used Consumes in RequestMapping Still i am getting POST http://localhost:8089/campaignManager/save.web 415 (Unsupported Media Type) Error.
请让我知道解决方法.我尝试了很多
please let me know the solution. i tried lot
推荐答案
我解决了我的错误.(415错误)
I resolved my error.(415 Error)
我将从控制器中删除@RequestBody.
I shd remove @RequestBody from my controller..
这篇关于415在ajax调用Spring MVC中发送JSON对象不支持的媒体类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!