我在此POST请求中收到400错误的请求。知道这里的问题是什么吗?日志在这里。

控制者

@Controller

public class AjaxController {

@RequestMapping(value="/addKeys", method=RequestMethod.POST, consumes="application/json; charset=UTF-8")

public ResponseEntity addKeys(@RequestParam(value="keys") ArrayList keys){

System.out.println("::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"+keys);

}

}

context-Servlet.xml

阿贾克斯

tmpList = '[{"key":"camera","label":"Camera"},{"key":"mobile","label":"Mobile"}]';

$.ajax({

type: 'POST',

url: ctx+'/ajx/addKeys',

data: JSON.stringify({"keys": tmpList }),

success: function(r){

if(r.model.status=='success'){

debugger;

//glist.push(elem.key);

//addToList(elem.key, elem.label);

highlightInfoDisc();

}

},

dataType: 'json',

contentType: 'application/json'

});

FireBug-URL

http://localhost:8080/Di/ajx/addKeys

Firebug-响应标头

Cache-Control must-revalidate,no-cache,no-store

Content-Length 1384

Content-Type text/html; charset=iso-8859-1

Server Jetty(6.1.26)

Firebug-请求标头

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

Accept-Encoding gzip, deflate

Accept-Language en-us,en;q=0.5

Connection keep-alive

Content-Length 74

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

Cookie JSESSIONID=7mymobst47ig1s7uqy2z1fvx4

Host localhost:8080

Referer http://localhost:8080/Di/tiles/entNews.htm

User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1

X-Requested-With XMLHttpRequest

萤火虫-来源

{"keys":[{"key":"canon","label":"Canon"},{"key":"ricoh","label":"Ricoh"}]}

Firebug-回应

"NetworkError: 400 Bad Request - http://localhost:8080/Di/ajx/addKeys"

Logo

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

更多推荐