How to prevent static resources from being handled by front controller servlet which is mapped on /*

前端 未结 2 1192
被撕碎了的回忆
被撕碎了的回忆 2020-12-08 17:13

I have a servlet which acts as a front controller.

@WebServlet(\"/*\")

However, this also handles CSS and image files. How can I prevent th

2条回答
  •  臣服心动
    2020-12-08 17:23

    I know this is an old question and I guess @BalusC 's answer probably works fine. But I couldn't modify the URL for the JSF app am working on, so I simply just check for the path and return if it is to static resources:

        String path = request.getRequestURI().substring(request.getContextPath().length());
        if (path.contains("/resources/")) {
            return;
        }
    

    This works fine for me.

提交回复
热议问题