If you don’t want to see clear text in the url, such as http://localhost:8080/template_1/login.action?user=张三
, you can use js’s encodeURI and URLDecoder.decode together to decode the url. Under encryption
(1) JS puts the data on the page var val = encodeURI(encodeURI("The value to be transmitted to the server is the value")); //Call encodeURI 2 times
href= "<%=basePath%>recordManager/test_js_decodeURI.action?params=" val
(2) Server side like this
HttpServletRequest request = ServletActionContext.getRequest();
String vString = request.getParameter("params");
System.out. println("Before conversion:" vString);
String deString = URLDecoder.decode(vString, "UTF-8");
System.out.println("After conversion:" deString);
UTF-8 is consistent with the encoding on the page. For example: pageEncoding="UTF-8" on the jsp page, here is UTF-8
You can see it by right-clicking on the encoding on IE. If pageEncoding="UTF-8" on jsp, the right-click encoding on ie is uncode (UTF-8), if pageEncoding="GBK" on jsp, then the right-click encoding on ie (simplified Chinese gb2312)
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn