Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 自定义404页css?_Spring_Spring Mvc - Fatal编程技术网

Spring 自定义404页css?

Spring 自定义404页css?,spring,spring-mvc,Spring,Spring Mvc,我一直在为我的html页面使用thymeleaf创建一个简单的站点,通常我的css链接有点像这样 <link href="../static/css/bootstrap.css" th:href="@{css/bootstrap.css}" rel="stylesheet" media="screen"/> 在服务器启动时,我缺少什么使其无法工作?我建议查看您的spring上下文文件,并检查资源是否映射到文件夹 <mvc:resources mapping="/res

我一直在为我的html页面使用thymeleaf创建一个简单的站点,通常我的css链接有点像这样

<link href="../static/css/bootstrap.css"
    th:href="@{css/bootstrap.css}" rel="stylesheet" media="screen"/>

在服务器启动时,我缺少什么使其无法工作?

我建议查看您的spring上下文文件,并检查资源是否映射到文件夹

<mvc:resources mapping="/resources/**" location="<path to resources>" />

当您使用时:

<link href="../static/css/bootstrap.css"
    th:href="@{css/bootstrap.css}" rel="stylesheet" media="screen"/>
该值:
/css/bootstrap.css
将替换原始href的
./static/css/bootstrap.css


话虽如此,页面的源代码还是用来计算你的href从
th:href
标签中得到了什么值的。资源并不是这样映射的。。。所以这似乎不是问题。谢谢你的信息!这最终让我意识到问题所在。显然404页面没有被解析为thymeleaf页面,我想这是有道理的,我所要做的就是把它当作普通的html。
<link href="../static/css/bootstrap.css"
    th:href="@{css/bootstrap.css}" rel="stylesheet" media="screen"/>
href=/css/bootstrap.css