JSP doesn't open CSS, Images and JS

前端 未结 3 1834
隐瞒了意图╮
隐瞒了意图╮ 2020-12-20 08:35

I\'m trying to put CSS, JS and IMGs on my JSP, but doesn\'t work, it\'s strange because I use c:url and \"jstl/core\"

I\'m use JSP, jstl and servlet, no

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-20 08:47

    The url pattern "/" has a special meaning to the web server. It's used for default servlet mapping which is capable of serving the static content. The static content is JS, CSS, images, html resources. Directing these files to your servlet is wrong, because it's not capable to serve the static content.

    Change the servlet mapping to something @WebServlet(urlPatterns="/incidente")

    and use url localhost:8080/PainelProduct/incidente to forward to jsp page.

    Check this question to learn more about servlets and servlet mapping Mapping a specific servlet to be the default servlet in Tomcat.

提交回复
热议问题