On the issue of static resource failure after page jump

On the issue of static resource failure after page jump

During application development, static resources such as styles and pictures cannot be loaded after the page jumps. This is mainly because the path of the current file has changed, and no static resources can be found under the current path.
Insert picture description here

One, use thymeleaf template engine development

Using the url access syntax of the thymeleaf template @{}, when accessing static resources, the root path of the current application will be automatically added to you.

<link th:href="@{/asserts/css/signin.css}" rel="stylesheet">

Two, JSP template engine

If you are using JSP, you can use it ${pageContext.request.contextPath}to get the current root path.

<form action="${pageContext.request.contextPath}/login"> </form>

Guess you like

Origin blog.csdn.net/glpghz/article/details/111057774