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

沒有留言:

張貼留言

關於一點神的帶領

開始工作差不多兩周 確定工作後, 聚會就慢慢穩定下來 會選擇這工作, 我記得那天是跪下來 禱告說, 我想走一條對的道路, 做一個正常的人, 過正常的日子 我感覺中這工作比做駐點的更有一點正常的味道 雖然駐點能給的薪水和這份有差距到2.5萬每月 我感覺裡面清楚了, 知道要走的路, ...