url中,中文乱码的问题

1// 在jsp中
2 String add  = java.net.URLEncoder.encode("添加", "utf-8");
3 add = java.net.URLEncoder.encode(add, "utf-8");
4//在from标签中5 <form action="Servlet/FinancialServlet?topic=<%=add %>" method="POST" >

在接收方

1 String topic = request.getParameter("topic");
2 topic = java.net.URLDecoder.decode(topic, "utf-8");

这样接收到的就不是乱码啦

猜你喜欢

转载自blog.csdn.net/xiaoliuyiting/article/details/53788374