Solve the Chinese problem introduced by Response.sendredirect

xiaoxiao2021-03-06  44

//test1.jsp

<% @ Page ContentType = "Text / HTML; Charset = GB2312"%> <% string sname = "Hello"; response.sendredirect ("test2.jsp? name =" java.net.urlencoder.encode (sname) );%> // Test2.jsp

<% @ Page ContentType = "Text / HTML; Charset = GB2312"%> <% string str = new string (Request.getParameter ("name"). getBytes ("ISO8859_1"), "GB2312"); Out.print STR);%> Now enter http://127.0.0.1:8080/test1.jsp in the browser, you can correct the Chinese parameters to the Test2.jsp page, and correct Chinese parameters correctly in the Test2.jsp page . And no longer a garbled situation.

转载请注明原文地址:https://www.9cbs.com/read-79841.html

New Post(0)