Nginx 配置

# Tomcat 监听地址
location / {
    proxy_pass          http://localhost:18443;
}

# 处理静态资源
location ~ .*\.(js|css|gif|jpg|jpeg|png|bmp|swf)?$ {
    proxy_pass          http://localhost:18443$request_uri;
    proxy_redirect      off;
    proxy_set_header    X-Real-IP $remote_addr;
    proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header    Host $http_host;
}

Thymeleaf 文件对 CSS,JS 文件的处理

# CSS
<link type="text/css" th:href="@{css/bootstrap4/bootstrap.min.css}" rel="stylesheet">
# JS
<script type="text/javascript" th:src="@{js/jquery/jquery-3.6.0.min.js}" ></script>
<script type="text/javascript" th:src="@{js/bootstrapjs/bootstrap.bundle.min.js}"></script>

Springboot 配置文件

# Thymeleaf Configuration
spring.thymeleaf.cache=false # 是否开启缓存
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.mode=HTML
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html

静态文件都放在src/main/resources/static目录中。

标签: none

评论已关闭