1. Problem elicitation
When doing an announcement browsing function, as long as a parameter value passed through url contains & or, a problem occurs - the value of the variable cannot be displayed.
Problem positioning result: When encountering &, the value of this parameter will be automatically truncated, resulting in incorrect parameter value transmission.
2. Solve the problem
The following tests are done in the java code:
String charEncode = java.net.URLEncoder.encode("&");
System.out.println("character& translated value is: " + charEncode ); //Output: %26
Therefore, the solution appears -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
eg:
var url = "page.jsp?para1=a&b"
Make the following modifications:
var url = "page.jsp?para1=a%26b";
At this point, the problem has been successfully solved. n_n
The above article url passes the parameter value and the solution to the url automatic truncation problem is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.