gpt4 book ai didi

java - 加载资源 css 文件失败。自由标记

转载 作者:行者123 更新时间:2023-11-28 00:12:54 24 4
gpt4 key购买 nike

@英语不是我的第一语言。

我在 spring 元素中使用 freemaker。但是我无法链接 css 文件。

Here tree and code

错误:获取 http://localhost:8080/static/style.css净::ERR_ABORTED 404 登录:6

<link rel="stylesheet" href="/static/style.css"/>没有错..

Error

<#macro page>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Getting Started: Serving Web Content</title>
<link rel="stylesheet" href="/static/style.css"/>
<#--<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">-->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">

</head>
<body>
<#nested>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</body>
</html>
</#macro>

最佳答案

您如何配置 /src/main/resources/static 目录来提供文件?

如果您使用 Spring Boot 及其默认配置,则 static 不是 URL 路径的一部分,因此您应该使用

<link rel="stylesheet" href="/style.css"/>

关于java - 加载资源 css 文件失败。自由标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55278524/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com