JS get URL parameters and URL encoding, decoding
The complete URL consists of these parts: Scheme://host:port/path?query#fragment, the various parts are as follows:
Window.location.href: The way to get the full URL: scheme://host:port/path?query#fragment
Window.location.protocol: Get Rul protocol scheme
Window.location.host: Get Host
Window.location.port: Get port number
Window.location.pathname: Get URL path
Window.location.search: Get the parameter query section, and note what is returned here? query
Window.location.hash: Gets the anchor point, #fragment
In JS you can use Escape (), Encodeurl (), encodeURIComponent (), and three methods have some symbols that will not be encoded:
Escape (): @ */+
Encodeurl ():! @ # $& * () =:/;? +
encodeURIComponent ():! * ( ) ‘
Urldecoder.decode ("Chinese", "UTF-8") can be used on the Java side to decode
However, since the encoding has been decoded by using request.getparameter () to get the parameters, it is generally only used in JS
encodeURIComponent ("Chinese");
Use Request.getparameter () directly on the Java side to get back to Chinese.
If you want to use Urldecoder.decode ("Chinese", "UTF-8") on the Java side, decoding can also be encoded in JS two times, namely:
encodeURIComponent (encodeURIComponent ("Chinese"));
If you do not encode two times, the Java side through the Decode method will be garbled.
JavaScript URL correlation function (escape/encodeurl/encodeuricomponent difference)