This article describes the solution to the garbled code in Chinese in the js value transmission background. Share it for your reference, as follows:
In the "test.jsp" page, the value needs to be passed to the background through js. When the background searches for data based on the passed value, it is encoded through the js of test.jsp (code for the annotation part), and the background Java decode (the annotation part is decoded), which can be solved.
test.jsp:
<script type="text/JavaScript" charset="UTF-8">function test(){//The following two lines of code encode the value passed by js: var faultAddr = encodeURI(document.getElementById("faultAddr").value); faultAddr = encodeURI(faultAddr); //It is necessary to encode twice window.frames["listframe"].location.href ="queryorderList.action?faultAddr=" + faultAddr ;}</script>…<tr><td>Complaint Address</td> <td> <input id="faultAddr" maxlength="300" size="10" name="faultAddr" type="text" value=""/> </td></tr>Java code:
String faultAddr = request.getParameter("faultAddr");try{ faultAddr = URLDecoder.decode(faultAddr , "utf-8");//Encoding and decoding}catch(Exception e){ e.printStackTrace();}For more information about JavaScript related content, please check out the topics of this site: "Summary of JavaScript encoding operation skills", "Summary of JavaScript value transmission operation skills", "Summary of json operation skills in JavaScript", "Summary of JavaScript switching effects and techniques", "Summary of JavaScript search algorithm skills", "Summary of JavaScript animation effects and techniques", "Summary of JavaScript errors and debugging techniques", "Summary of JavaScript data structures and algorithm skills", "Summary of JavaScript traversal algorithms and techniques" and "Summary of JavaScript mathematical operation usage"
I hope this article will be helpful to everyone's JavaScript programming.