我试图添加一个登录的东西,但后来整个事情停止了正常工作。我的意思是:
拒绝应用来自'http://localhost:8080/login‘的样式,因为其MIME类型('text/html')不是支持的样式表MIME类型,并且启用了严格的MIME检查。
我在这上面花了大概3个小时。
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head>
<title>Logging </title>
<link rel="stylesheet" href="loginStyle.css" type="text/css" />
</head>
<body>
<div class="image-bg">
<div class="login">
<div class="allarms">
<div th:if="${param.error}">
Wrong password
</div>
<div th:if="${param.logout}">
Logged out
</div>
</div>
<form th:action="@{/login}" method="post" id="form-login">
<div><label> User : <input type="text" name="username" />
</label></div>
<div><label> Password <input type="password" name="password" /> </label>
</div>
<div id="input-login"><input type="submit" value="Log in" /></div>
</form>
</div>
</div>
</body>
</html>这是我的css文件:
body {
padding: 0;
margin: 0;
width: 100%;
height: 100%;
text-align: center;
}
.image-bg {
background-image: url("bgimage.jpg");
background-repeat: no-repeat;
height: 900px;
background-size: cover;
position: relative;
background-position: center;
}
.login {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
font-size: 40px;
}
.login .form-login {
padding: 5px;
}
.login .allarms {
color: red;
font-weight: 900;
}PS
一些奇怪的事情发生了..。我已经添加了一个新的html文件与新的css文件和旧的错误返回到这个新的HTML文件- lol?我得到了这个错误:
拒绝应用来自'‘的样式,因为其MIME类型('application/json')不是支持的样式表MIME类型,并且启用了严格的MIME检查。
但是旧的HTML文件可以正确加载css文件。
发布于 2019-01-23 04:29:11
如果你在浏览器中使用inspector,它会显示任何错误吗?如果您检查Network选项卡,是否看到加载了任何文件?我看到你在使用spring security,你允许所有人加载你的资源吗?
https://stackoverflow.com/questions/54315892
复制相似问题