jsp post/get中接处理
以参数:username为便
post接收中文比get接收中文要方便多了。
1 <%@ page contentType="text/html;charset=gb2312"%>2 <%3 request.setCharacterEncoding("gb2312");4 String username = (String) request.getParameter("username");5 %>
get接收中文(非常麻烦):
1 <%@ page contentType="text/html;charset=gb2312"%> 2 <% 3 String username = request.getParameter("username"); 4 byte[] bytes = username.getBytes("iso-8859-1"); 5 String result = new String(bytes, "gb2312"); 6 out.print(result); 7 8 String s =new String( new String(request.getParameter("username").getBytes("iso-8859-1") , "gb2312") ); 9 out.print(s);10 %>