在jquery ajax上持续接收400(错误请求)到MVC控制器。 我试图发送带有和不带有JSON.stringify ...的简单数据,数组,但我的想法耗尽了。 还有什么呢?

Ajax发送

$.ajax({

type: 'POST',

url: '../../taskaction/send',

data: JSON.stringify({idTaskAction: 2, actioname: 3}),

success: function (data, textStatus, jqXHR) {

console.log('@Success sending action status: ' + textStatus);

},

error: function(jqXHR, textStatus, errorThrown){

console.log('@Error sending action status: ' + textStatus);

},

contentType: "application/json; charset=utf-8",

dataType: "json"

});

弹簧控制器

@RequestMapping(value = "/taskaction/send",

method = RequestMethod.POST,

produces = "application/json")

@ResponseBody

public Map sendAction(Principal principal,

@RequestBody Map data, @PathVariable Long id) {

logger.info("Task controller /taskaction/send ...");

String actionname = (String) data.get("actionname");

System.out.println("*****>>>>>>" + actionname );

Map rdata = new HashMap();

TaskAction action = null;

rdata.put("success", true);

return rdata;

}

检查员的HTTP请求

Remote Address:127.0.0.1:8080

Request URL:http://localhost:8080/myTasks/taskaction/send

Request Method:POST

Status Code:400 Petición incorrecta

Request Headersview source

Accept:application/json, text/javascript, */*; q=0.01

Accept-Encoding:gzip,deflate

Accept-Language:es-ES,es;q=0.8,en;q=0.6

Connection:keep-alive

Content-Length:33

Content-Type:application/json; charset=UTF-8

Cookie:JSESSIONID=9073BF5FA653C2C673AD9BCB787732C3

Host:localhost:8080

Origin:http://localhost:8080

Referer:http://localhost:8080/myTasks/task/upd/8

User-Agent:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36

X-Requested-With:XMLHttpRequest

Request Payloadview source

{idTaskAction:2, actionname:3}

actionname: 3

idTaskAction: 2

Response Headersview source

Connection:close

Content-Language:es

Content-Length:990

Content-Type:text/html;charset=utf-8

Date:Sat, 20 Sep 2014 13:19:31 GMT

Server:Apache-Coyote/1.1

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐