3.2K Star 8.8K Fork 3.6K

GVPJFinal / JFinal

 / 详情

ext包内的handler类FakeStaticHandler的处理问题

已完成
创建于  
2015-07-29 10:27

源码:

public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
        if("/".equals(target)) {
            this.nextHandler.handle(target, request, response, isHandled);
        } else if(target.indexOf(46) == -1) {
            HandlerKit.renderError404(request, response, isHandled);
        } else {
            int index = target.lastIndexOf(this.viewPostfix);
            if(index != -1) {
                target = target.substring(0, index);
            }

            this.nextHandler.handle(target, request, response, isHandled);
        }
    }

中间执行} else if(target.indexOf(46) == -1) {这句话验证请求地址里有没有.

如果请求地址是:http://www.xxx.com/user/abc.html 这样的地址完全没问题,可以处理掉后面的.html

但是如果地址是:http://www.xxx.com/user/abc 这样的地址,断点进去看到target的值是/user/abc这个地址也是合法的,本不应该过滤后缀直接进入到controller中,但因为上面还有一层处理.的逻辑,导致直接报错了

不知道当初开发这个handler的时候是出于什么初衷还要过滤一下.

评论 (2)

FackStaticHandler 是做所谓的伪静态功能,也即,所有请求全都带有 ".html" 或者别的什么 ".xxx" 式的后缀,如果没有后缀反而是不允许的请求,这样就保证了同一个资源的 url 的唯一性

状态更改为 已关闭

登录 后才可以发表评论

状态
负责人
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
参与者(2)
840 jfinal 1580661334 Violation
Java
1
https://gitee.com/jfinal/jfinal.git
git@gitee.com:jfinal/jfinal.git
jfinal
jfinal
JFinal

搜索帮助

53164aa7 5694891 3bd8fe86 5694891