• IE浏览器报400错误:Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986


    前言:

    在用IE浏览器时访问tomcat项目时,页面报400错误,后台错误:

    java.lang.IllegalArgumentException: Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 3986
    

    在网上查得资料时因为Tomcat版本在7以后会对http头进行验证,不符合规范的就会抛出异常
    而IE浏览器无法对URL自动转义

    解决办法:

    1.使用encodeURI函数

    2.JS使用post请求

    //发送POST请求跳转到指定页面
    function httpPost(URL, PARAMS) {
        var temp = document.createElement("form");
        temp.action = URL;
        temp.method = "post";
        temp.style.display = "none";
    
        for (var x in PARAMS) {
            var opt = document.createElement("textarea");
            opt.name = x;
            opt.value = PARAMS[x];
            temp.appendChild(opt);
        }
    
        document.body.appendChild(temp);
        temp.submit();
    
        return temp;
    }
    
  • 相关阅读:
    Git编译安装
    ES集群
    索引、分片以及副本的数量和大小原则:
    初识ELK
    zabbix自定义监控项没权限读取文件问题
    Zabbix的图形界面中文变成□□问题
    logrotate
    rsync
    Linux下的mail指令
    nohup
  • 原文地址:https://www.cnblogs.com/wutongshu-master/p/12172741.html
Copyright © 2020-2023  润新知