zoukankan      html  css  js  c++  java
  • Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC

    解决Invalid character found in the request target. The valid characters are defined in RFC 7230 and RFC 问题

    通过这里的回答,我们可以知道:

    Tomcat在 7.0.73, 8.0.39, 8.5.7 版本后,添加了对于http头的验证。

    具体来说,就是添加了些规则去限制HTTP头的规范性

    参考这里

    具体来说:

    org.apache.tomcat.util.http.parser.HttpParser#IS_NOT_REQUEST_TARGET[]中定义了一堆not request target

    if(IS_CONTROL[i] || i > 127 || i == 32 || i == 34 || i == 35 || i == 60 || i == 62 || i == 92 || i == 94 || i == 96 || i == 123 || i == 124 || i == 125) {
                    IS_NOT_REQUEST_TARGET[i] = true;
                }

    转换过来就是以下字符(对应10进制ASCII看):

    • 键盘上那些控制键:(<32或者=127)
    • 非英文字符(>127)
    • 空格(32)
    • 双引号(34)
    • #(35)
    • <(60)
    • >(62)
    • 反斜杠(92)
    • ^(94)
    • TAB上面那个键,我也不晓得嫩个读(96)
    • {(123)
    • }(124)
    • |(125)

    解决办法:

    还是参考这里

    即:

    配置tomcat的catalina.properties

    添加或者修改:

    tomcat.util.http.parser.HttpParser.requestTargetAllow=|{}

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^我是华丽的分割线^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    在上次遇到此问题时,以上的解决方案是木有问题的。但是今天又遇到了此问题,我使用如上的解决方案却不行,最后通过请求的json数据进行urlencode编码,遂解决,代码如下:

        //导出
        function toExport(exportType) {
            bootbox.confirm("您确定要导出吗?", function(r){
                if(r){
                    var queryParam = getParam();
                    //导出excel类型  0 导出本页  1 导出全部
                    if(exportType=='0'){
                        queryParam.push({ "name": "exportType", "value": "0"});
                        //location.href = "${pageContext.servletContext.contextPath}/sys/ordermain/exportOrders?queryParam="+JSON.stringify(queryParam)+"&aoData="+JSON.stringify(aoDataAboutExport);
                        var queryParamDeal=encodeURIComponent(JSON.stringify(queryParam));
                        var aoDataDeal=encodeURIComponent(JSON.stringify(aoDataAboutExport));
                        location.href = "${pageContext.servletContext.contextPath}/sys/ordermain/exportOrders?queryParam="+queryParamDeal+"&aoData="+aoDataDeal;
                    }else{
                        queryParam.push({ "name": "exportType", "value": "1"});
                        //location.href = "${pageContext.servletContext.contextPath}/sys/ordermain/exportOrders?queryParam="+JSON.stringify(queryParam);
                        var queryParamDeal=encodeURIComponent(JSON.stringify(queryParam));
                        location.href = "${pageContext.servletContext.contextPath}/sys/ordermain/exportOrders?queryParam="+queryParamDeal;
                    }
                    
                }
            });
        }
  • 相关阅读:
    poj 3304线段与直线相交
    poj 1039 几何没思路
    zoj 1010 (线段相交判断+多边形求面积)
    poj 1654 Area (多边形求面积)
    poj 3348--Cows(凸包求面积)
    zoj 2107&&hdu 1007最近点对问题
    Codeforces Round #260 (Div. 2)AB
    MMORPG大型游戏设计与开发(part1 of net)
    MMORPG大型游戏设计与开发(规范)
    MMORPG大型游戏设计与开发(构架)
  • 原文地址:https://www.cnblogs.com/hedongfei/p/8418010.html
Copyright © 2011-2022 走看看