zoukankan      html  css  js  c++  java
  • response.sendRedirect()重新定向的乱码问题

    这里response.sendRedirect("YPbianhaoModify.jsp?jinhuoshang="+jinhuoshang+"&jinhuoriqi="+jinhuoriqi)要是有中文的话就成了
    response.sendRedirect("YPbianhaoModify.jsp?jinhuoshang=进货商&jinhuoriqi=2007-09-23");

    这里的中文不进行处理,重定向的时候必然会出现http://127.0.0.1:8080/medicine/YPbianhaoModify.jsp?jinhuoshang=??om?jinhuoriqi=2007-09-23  

    用URLEncoder.encode()方法对中文处理

    如:
    String url = "YPbianhaoModify.jsp?jinhuoshang="+jinhuoshang+"&jinhuoriqi="+jinhuoriqi;
    response.sendRedirect(URLEncoder.encode(url,"GBK"));//GBK是页面的编码格式,可根据情况修改
    //response.sendRedirect(URLEncoder.encode(url));

  • 相关阅读:
    shell的正则表达式
    shell语法
    shell通配符
    shell小命令
    DNS
    CCNA参考链接
    Network problem solving flow chart
    我是一个路由器
    我是一个网卡
    Chrome
  • 原文地址:https://www.cnblogs.com/handsome1013/p/4870921.html
Copyright © 2011-2022 走看看