Js Code:
Function doFind (default_value ){
Var q_bureau_name = document. forms [0]. q_bureau_name.value;
Var defpars = '';
If (default_value! = Null ){
Defpars = '& default_value =' + default_value;
}
Var url = 'mermeroperaction. do ';
Var pars = 'Action = getbureaulist & sname = customerTel. TEL_BUREAU & q_bureau_name = '+ encodeURI (q_bureau_name) + defpars; // encodeURI encodes text strings into a valid Uniform Resource Identifier (URI) twice ).
Var my = new Ajax. Request (url, {method: 'post', parameters: pars, onComplete: show });
}
Function show (originalRequest)
{
Var BUREAUSPAN = document. getElementById ("BUREAUSPAN ");
BUREAUSPAN. innerHTML = originalRequest. responseText;
}
Java code
String q_bureau_name = Util. filter (request. getParameter ("q_bureau_name "));
Q_bureau_name = java.net. URLDecoder. decode (q_bureau_name, "UTF-8 ");
// Ajax submits data (post) in UTF-8 format by default, using the escape () or encodeURI () method provided by javascript. use java.net. URLDecoder. decode (value, "UTF-8") method for decoding.
Js knowledge:
Escape Method
PairStringObject encoding so that they can be read on all computers,
escape(charString)
RequiredCharstringThe parameter is arbitrary to be encoded.StringObject or text.
Description
EscapeMethod returnsCharstringThe string value of the content (in Unicode format ). All spaces, punctuation marks, accents, and other non-ASCII characters are used%XxEncoding, whereXxEqual to the hexadecimal number of the character. For example, "% 20" is returned by a space ".
If the character value is greater than 255% UXxxxFormat storage.
Note: EscapeThe method cannot be used to encode the Uniform Resource Identifier (URI. Encoding should be usedEncodeURIAndEncodeURIComponentMethod.
EncodeURI Method
Encodes a text string into a valid Uniform Resource Identifier (URI ).
encodeURI(URIString)
RequiredURIStringThe parameter represents an encoded URI.
Description
EncodeURIMethod returns an encoded URI. If you pass the encoding resultDecodeURI, Then the initial string is returned.EncodeURIThe method does not encode the following characters: ":", "/", ";", and "? ". Please useEncodeURIComponentTo encode these characters.
EncodeURIComponent Method
Encodes a text string into a valid component of a uniform resource identifier (URI.
encodeURIComponent(encodedURIString)
RequiredEncodedURIStringThe parameter represents an encoded URI component.
Description
EncodeURIComponentReturns an encoded URI. If you pass the encoding resultDecodeURIComponent, Then the initial string is returned. BecauseEncodeURIComponentMethod to encode all characters. Note that if the string represents a path, for example/Folder1/folder2/default.htmlThe slash is also encoded. In this way, when the encoding result is sent to the web server as a request, it will be invalid. If the string contains more than one URI component, useEncodeURIMethod.