Springboot project context-path problem?

recently, when I was learning to do a springboot project, I encountered two headaches:

when changes the value of context-path configuration

    The loading path of
  1. css, js, image and other files will also be changed, some with the value of context-path configuration
  2. routing navigation through @ GetMapping can also go wrong.

question:

mature things must have mature general solutions. How can I set or modify the resource file and the current route so that the error will not be affected by the change of the context-path configuration value? Xiaobai asks the great god for advice

Aug.07,2021

there are all kinds of ways to deal with it, and I don't seem to think which one is more general.
there is a very important problem: before your page is visited, the path is uncertain ! And according to the sevlet specification, this path is under session. That is to say, each visit may be different, so any method of writing death will make the project rigid and lose some of the flexibility of the definition.

< H1 > spring tags, for jsp < / H1 >
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<spring:url value="/css/main.css" var="springCss" />
< H1 > < c:url/ > for jsp < / H1 >
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<c:url value="/css/main.css" var="jstlCss" />
<link href="${jstlCss}" rel="stylesheet" />

< H1 > webjars sevlet method, which can be used on jsp and html static pages < / H1 >

the idea is to package static pages and access them through a specific url prefix, which is handled by the interceptor or sevlet

maven pom.xml configuration:


<dependency>
        <groupId>org.webjars</groupId>
        <artifactId>bootstrap</artifactId>
        <version>3.3.7</version>
    </dependency>

Page template:

<link rel="stylesheet" type="text/css" href="webjars/bootstrap/3.3.7/css/bootstrap.min.css" />

< H1 > html base tagging method < / H1 > < H2 > jsp, ftl & etc. < / H2 >

if you want to separate movement and movement, you need to define several different variables and inject them from the backend

.
<!-- base  sitemesh ,  -->
<base href="${host}/${context}/${language}/">
...<!--  -->
<link rel="stylesheet" href="css/style.css" />
<script src="js/script.js"></script>
...
<a href="home">home</a>
<a href="faq">faq</a>
<a href="contact">contact</a>
...
<img src="img/logo.png" />
< H2 > html static, write dead directly, or also relative path < / H2 >
<base href="http://example.com/en/" />
<!--  IE  -->
<!--  -->
<base href="//example.com/somefolder/"> 
<!--  -->
<base href="/somefolder/">

it is not good to write dead at present, but if it is only in a few places, it is reluctantly acceptable

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3ba08-2c28d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3ba08-2c28d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?