JS in the URL to pass the Chinese characters garbled

Source: Internet
Author: User

Recently used Easyui to make a drop-down box, after entering a value fuzzy query according to a value:

$ (' #comboboxA '). ComboBox ({
url:basepath+ ' Form/formlistforcombobox ',
Method: ' Get ',
Valuefield: ' FormId ',
TextField: ' Formdisplayname ',
PANELHEIGHT:200,
Multiple:false,
Keyhandler: {
Up:function (e) {//"Up ARROW" to defer processing
},
Down:function (e) {//"down arrow" to defer processing
},
Enter:function (e) {//"enter" to defer processing
var Inputtext = $ (' #comboboxA '). ComboBox (' GetText ');
var url = basepath+ ' form/searchformlist ' + '? inputtext= ' + Inputtext;
$ (' #comboboxA '). ComboBox (' reload ', url);
$ (' #comboboxA '). ComboBox (' SetValue ', inputtext);
/*$.ajax ({
Type: ' Post ',
url:basepath+ ' Form/searchformlist ',
data:{' Inputtext ': Inputtext},
DataType: ' JSON ',
Success:function (formoptionlist) {
Console.log (formoptionlist);
},
Error:function (Result) {
if (Result! = ' null ' && result! = ') {
$.messager.alert ("Hint", "An unknown error has occurred!") ");
}
}
});*/
},
Query:function (keyword) {//"Dynamic Search" processing
}
}
});

where the var url = basepath+ ' form/searchformlist ' + '? inputtext= ' + Inputtext;

This line uses the Get method to pass the parameter (the URL is followed directly by the argument is get, the parameter is placed in the data{"Inputtext": "Inputtext"} for the Post method).

And if you do not configure about 64 rows of Servers\tomcat v7.0 Server at Localhost-config\server.xml:

<connector uriencoding= "UTF-8" connectiontimeout= "20000" port= "8080" protocol= "http/1.1" redirectport= "8443"/ The > will appear garbled in Chinese.



This garbled language also has a solution:

JS: var url = basepath+ ' form/searchformlist ' + '? inputtext= ' + encodeURI (inputtext, "UTF-8");

Controller: String inputtextval = new String (Inputtext.getbytes ("iso-8859-1"), "UTF-8");

However, the first method is more recommended, directly in the configuration of the convenience.


JS in the URL to pass the Chinese characters garbled

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.