get请求参数为中文是乱码的问题

    xiaoxiao2021-04-11  37

    request.setCharacterEncoding("UTF-8"); //java代码中这样设置一下,将请求编码改为utf-8,但是只对post方式有效 String path= request.getParameter("documentPath"); //得到传过来的中文参数 String method = request.getMethod(); //获取提交方式  if(method!=null && "GET".equals(method)){ //如果是get的方式的话  path= new String(path.getBytes("ISO8859-1"), "UTF-8"); //(这里的UTF-8取决于jsp页面的编码)这样得到的path就不会是乱码了
    转载请注明原文地址: https://ju.6miu.com/read-666712.html

    最新回复(0)