方案一:

GET:POST

对于中文字段,客户端使用URLEncoder.encode()方法进行一次编码

服务器使用:String data=new String(request.getParameter("title").getBytes("ISO-8859-1"),"UTF-8");解码

个人觉得这种方法挺麻烦的,喜欢采用方案二

方案二:

GET:客户端使用URLEncoder.encode(URLEncoder.encode(username,"UTF-8"), "UTF-8")对中文字段进行两次编码

POST:客户端使用URLEncoder.encode(username,"UTF-8");只进行一次编码就行了,经测试编码两次也行

服务端使用String username=URLDecoder.decode(request.getParameter("username"),"utf-8");进行一次解码

感觉第二种方法通用性强一些

 

 

相关文章:

  • 2021-04-18
  • 2022-12-23
  • 2021-09-17
  • 2021-10-14
  • 2022-03-03
  • 2022-01-16
  • 2022-12-23
  • 2022-01-09
猜你喜欢
  • 2021-12-21
  • 2021-10-28
  • 2021-07-23
  • 2022-12-23
  • 2022-02-24
  • 2021-12-02
  • 2021-08-27
相关资源
相似解决方案