2014年5月15日星期四

response.getWriter () write (json);. unable to pass the value of the foreground , the problem is not the thread ?

callback function in this DLL :
public void OnGetCallRecordRspEnd () {
String Jsondata = JsonUtil.listToJson (list);
HttpServletResponse response = CallingLogAction.g_response;
OutPut.responseWritejson (response, Jsondata);
}
OutPut.responseWritejson achieve this :
public static void responseWritejson (HttpServletResponse response, String json) {
response.setContentType ("application / json; charset = utf-8");
if (json! = null) {
try {
response.getWriter () write (json).;
} catch (IOException e) {
/ / TODO Auto-generated catch block
e.printStackTrace ();
}
}
Here 's response I've set as global , so the callback function in a dynamic library OnGetCallRecordRspEnd () , and pass OutPut.responseWritejson () the response is not a library thread response. But why my reception by ajax request to accept less than the returned data ? That is my response.getWriter () write (json);. Json values ​​to the front desk did not , and why . I feel it is wrong corresponding request and response , however, how to solve it ? ~ ~ ~
pursuing big God ~ ~ ~ ~ ~
Thank you ~ ~ ~ ~

}
------ Solution ----------------------------------- ---------
printing error see error: function (XMLHttpRequest, textStatus, errorThrown) {
alert (XMLHttpRequest.status);
alert (XMLHttpRequest.readyState);
alert (textStatus);
}
- ---- For reference only ---------------------------------------
json ; the correct format without
------ For reference only ---------------------------------- -----


I'm sure is correct.
System.out.println () out

------ For reference only ---------------------------------- -----



json package is : [{"strBitrate": "", "strCallIP": "192.168.7.222", "strCallTime": "2014-5-7 14: 12:43 "," strCallType ":" breath "," strProtocol ":" H323 "," strTime ":" 00:00:01 "}, {" strBitrate ":" " ;, "strCallIP": "92.168.7.151", "strCallTime": "2014-5-7 14:12:41", "strCallType": " missed ", "strProtocol" ;: "H323", "strTime": "00:00:00"}]
------ For reference only ---------------- -----------------------
give you a reference to it.
------ For reference only ---------------------------------- -----
1. threading issues using ThreadLocal global object preservation response
2. writer to be called after the output of the flush method
------ For reference only ------------------------ ---------------


Thank you, I saw your reference .
Now my question is, at the end of the callback function that thread inside response.getWriter (). write (json) is unable to pass the value REQUEST request reception .
------ For reference only -------------------------------------- -
foreground how you write . You configure the application / json;

screen use json to deal with.
------ For reference only -------------------------------------- -



$. ajax ({
type: "POST",
url: "CallingLog",
dataType: "json",
contentType: "application / json; charset = utf-8",
success: function (Jsondata) {

This is the front desk , not wrong. I feel that request and response dislocation problems
------ For reference only ------------------------- --------------


Thank you ~ ~
This problem has been solved ~
because the message could not return to the front . Should return to the front of the message is blocked.
I set up in response to local needs sleep, after all acceptable parameters finished until the end of the message brought further response.

没有评论:

发表评论