JSP doesn't open CSS, Images and JS

这一生的挚爱 提交于 2019-11-29 12:30:27
Roman C

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.

You are not escaping the " when using inside the href value, use ' instead

I have encountered the same problem and have not resolved it for a long time. Then I realized that it was a problem from the path of the images.

Wrong path is like that;

src>main>resources>images

The order of files(path) should definitely be as follows.

src>main>webapp>resources>images

and you should to call the function like that;

<img src="<c:url value="/resources/img/logo.png"/>" alt=""/>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!