2014年1月2日星期四

jsonp problem solving ~ ~ ~ ~

$. ajax ({
type: "get",
url: "http://127.0.0.1:8080/payment/selectInfo?customerid =" + customerid ,
dataType: "jsonp",
jsonp: "callback",
jsonpCallback: "selectInfo",
data: {
customerid: customerid
},
success: function (data) {
alert ("data" + data);
},
error: function () {
alert (" Query Data Error ! " ) ;
}
});
novice first pass data with jsonp but customerid parameter is less than a backstage pass , background services that can be invoked to obtain the parameter is null, the following is the code behind :

@ Post ("selectInfo")
@ Get ("selectInfo")
public String selectInfo (@ Param ("customerId") String customerId, Invocation inv) {
paymentService.selectInfoByCustomerid (customer, inv);
return "";
}
seeking expert answers on how to get reception parameters passed with jsonp to achieve, and how to return to the front, thank you.
------ Solution ---------------------------------------- ----

customer i d

@ Param ("customer I d ") String customer I d,
------ For reference only ------------------- --------------------
response.setCharacterEncoding ("utf-8");
PrintWriter pw = response.getWriter ();
pw.print (json);
pw.flush ();

value request.getParameter ()

how your action handler class also with parameters ?
------ For reference only -------------------------------------- -
because integration framework project used , controller is equivalent to the action of the annotation is to tune the service name , then you can pass parameters , request to get less value .

------ For reference only ---------------------------------- -----
why did not cross domain with jsonp.
------ For reference only -------------------------------------- -
data: {
customerid: customerid
},
your url do not have to fight this to try to remove this .
------ For reference only -------------------------------------- -
because different service port is not the same tune port , so use jsonp ah
------ For reference only ----------------- ----------------------

A few days ago an article that jsonp pass parameters to such use before
.
data: {
customerid: "'" + customerid + "'"
}

url string and fight this one on the line with
------ For reference only --------------------- ------------------
Thank you . . The problem turned out to be careless , hey ~ ~

没有评论:

发表评论