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 %>

 

相关文章:

  • 2022-03-03
  • 2022-12-23
  • 2021-11-28
  • 2021-05-18
  • 2021-09-18
  • 2021-08-06
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-31
  • 2022-02-03
  • 2021-11-19
  • 2022-01-09
  • 2023-03-19
  • 2021-12-19
相关资源
相似解决方案