2021年5月18日 星期二

[Spring Boot] Thymeleaf 引用靜態資源

 拿到新的前端包,

要進到spring boot使用Thymleaf引入, 遇到了問題

還有爆

Refused to apply style from 'OOXXX' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

查了一下得知, 原來是資源沒有引入的問題,

後來查了一下才知道

放在static下面的靜態資源要這樣引入





引入程式碼如下



<script th:src="@{plugin/jquery.i18n-1.0.7/jquery.i18n.emitter.min.js}"></script>

 <script th:src="@{plugin/jquery.i18n-1.0.7/jquery.i18n.language.min.js}"></script>

<link rel="stylesheet" th:href="@{plugin/flatpickr-4.6.6/flatpickr.min.css}">

<link rel="stylesheet" th:href="@{plugin/flatpickr-4.6.6/themes/wistron.css}">


另外解決一直跳轉到login問題

import org.springframework.context.annotation.Configuration;

import org.springframework.security.config.annotation.web.builders.HttpSecurity;

import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;

import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

 

@Configuration

@EnableWebSecurity

public class SecurityConfigSEVEN extends WebSecurityConfigurerAdapter {

 

    @Override

    protected void configure(HttpSecurity http) throws Exception {

        //super.configure(http);

        //配置不需要登陆验证

        http.authorizeRequests().anyRequest().permitAll().and().logout().permitAll();

    }

 

}

參考網址:

https://blog.csdn.net/SEVENY_/article/details/104660418


參考網址: 

https://blog.csdn.net/chenbetter1996/article/details/84994801

https://stackoverflow.com/questions/48248832/stylesheet-not-loaded-because-of-mime-type

沒有留言:

張貼留言

Aider及gemini合併使用心得

嘗試Aider SDD套用gemini 我發現ai全自動產code有一個現象, 就是我心中有一個完美的想法, ai可能基於他的背景資訊未必想得到, 也或著就是ai已經被各種知識訓練過, 他可能選擇了一種, 但是並沒有查覺到其中有什麼問題, 很多時候的solution就是想得太簡單...