This feature has been in trial for a week, and there is no problem. The strange thing is that today there is a problem ??
Copy codeThe Code is as follows:
AjaxRequestObj. createEqStatusParameter = function (){
If (eqStatusArray. length <1 ){
Return;
}
Var paramNameArray = new Array ();
Var paramValueArray = new Array ();
// Retrieves the status Array
For (var index = 0, step = eqStatusArray. length; index <step; index ++ ){
Var tempEqStatusObj = eqStatusArray [index];
ParamNameArray. push (tempEqStatusObj. eqCode + "'" + tempEqStatusObj. opDateTime );
ParamValueArray. push (tempEqStatusObj. status );
}
// Break down and generate request strings.
Var paramStr = "";
ParamStr = paramStr. concat ("eqStatusNames ="). concat (encodeURIComponent (paramNameArray. join (","). concat ("&");
ParamStr = paramStr. concat ("eqStatusValues ="). concat (encodeURIComponent (paramValueArray. join ("'")));
Return paramStr;
};
XmlHttpObj. setRequestHeader ("Content-Type", "application/x-www-form-urlencoded ")
XmlHttpObj. send (param );
The client passes the parameter as a UTF-8 to the application, which can be obtained directly from the request when this parameter is used.
[Ajax receives Response Information]
Directly use forward to redirect to change the partial content of a div
Copy codeThe Code is as follows:
If ("doQueryRequest". equals (actParam )){
EquipUtils equipUtilsObj = EquipUtils. getInstance ();
// Obtain query parameters and splice them
EquipStatusMgrObj. setEquipCondition (equipUtilsObj. createEquipFilter (request ));
EquipStatusMgrObj. setEquipStatusCondition (equipUtilsObj. getEquipStatusDate (request ));
// Device information
List <DynaBean> equipArray = equipStatusMgrObj. queryEquip (null );
// Device status
Map <String, Map <String, String> equipStatusMapping =
EquipStatusMgrObj. queryEquipState4Map (equipArray, null );
SessionObj. setAttribute ("paginationEntity", equipStatusMgrObj. getPaginationEntity ());
SessionObj. setAttribute ("equipCondition", equipStatusMgrObj. getEquipCondition ());
SessionObj. setAttribute ("eqStatusCondition", equipStatusMgrObj. getEquipStatusCondition ());
Request. setAttribute ("equipList", equipArray );
Request. setAttribute ("dateList", equipStatusMapping );
Try {
Request. getRequestDispatcher ("/eq/detectPoint/InnerEqStatusRefresh. jsp"). forward (request, response );
} Catch (Exception e ){
E. printStackTrace ();
}
} Else if ("getPageToolBar". equals (actParam )){
PaginationEntity pEntity = (PaginationEntity) sessionObj. getAttribute ("paginationEntity ");
String tempStr = pEntity. getPaginationTool ();
OutputStream out;
Try {
Response. setContentType ("text/html; charset = UTF-8 ");
Out = response. getOutputStream ();
Out. write (tempStr. getBytes ("UTF-8 "));
Out. flush ();
Out. close ();
} Catch (IOException e ){
E. printStackTrace ();
}
}
Because, currently using xmlHttpObj. responseText, responseText is the UTF-8 by default, so it is a good choice to make the jump page into a UTF-8. At least don't worry about garbled characters ..
[Cause of garbled characters]
Previously, this function was coded in GB18030 format. So far, it was normal for other clients and colleagues' machines, but garbled characters appeared on the pages of my own machines. When I used this function to present the file unified use of UTF-8 OK, I do not know that xmlHttpObj touched the machine's nerves .. I checked some materials and found the international trend. The problem was solved, but the reason was not found!
[Found a Bug]
Response. setContentType ("text/html; charset = UTF8"); no error is thrown on my machine, but an error is thrown on my colleagues' machine.
Change response. setContentType ("text/html; charset = UTF-8"); All OK ..