如题,AJAX不带data的时候正常,有data出错
$.ajax({
type: "POST",
contentType: "application/json",
url:"/rest/saiku/"+Saiku.session.username+"/repository2/rename",
data: {queryname:"1234d"},//没有这一项,后台不取queryname的时候正常,输出OOO
success: function (msg) {
},
error: function (msg) {
}
});
@POST
@Produces({"application/json" })
@Path("/rename")
public void rename(@FormParam("queryname") String queryName)
{
System.out.println("OOO");
System.out.println(queryName);
}
错误信息如下:
前台错误:POST http://rest/saiku/cd/repository2/rename 500 (Erreur Interne de Servlet)
后台错误: Unexpected character ('q' (code 113)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
------解决方案--------------------
试一下:
$.ajax({
type: "POST",
url:"/rest/saiku/"+Saiku.session.username+"/repository2/rename",
data:"queryname=1234d",
success: function (msg) {
},
error: function (msg) {
}
});
------解决方案--------------------
type: "POST", 肯定要用form才可以获取到值
type:"GET",才是用query
------解决方案--------------------
直接在后面加url看看。
------解决方案--------------------
把data: {queryname:"1234d"}改成 data:"queryname=1234d"试试