小编Bat*_*ato的帖子

带有Thymeleaf的SpringBoot - 未找到css

首先要说的是,我现在一直在寻找解决方案,现在我非常绝望.

我在Spring Boot运行时无法从html页面访问css文件.

html.file

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
    <head lang="en">
        <title th:text='#{Title}'>AntiIntruder</title>
        <meta charset="UTF-8" />
        <link rel="stylesheet" type="text/css" media="all" href="../assets/css/style.css" th:href="@{/css/style.css}" />
    </head>
    <body>
...
Run Code Online (Sandbox Code Playgroud)

Application.java

@SpringBootApplication // adds @Configuration, @EnableAutoConfiguration, @ComponentScan
@EnableWebMvc
public class Application extends WebMvcConfigurerAdapter {

    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/assets/**").addResourceLocations("classpath:/assets/*");
    }
}
Run Code Online (Sandbox Code Playgroud)

文件夹结构:

文件夹结构

我已经尝试将css文件夹放入static文件夹和/或删除addResourcesHandlers,通过相对路径和其他一些东西引用css.似乎没有解决这个问题.请让我知道,如果你试图解决这个问题,但没有找到解决办法,那么我知道,我不会被忽视.

java thymeleaf spring-boot

11
推荐指数
3
解决办法
2万
查看次数

PyCharm 警告:字典上的过滤器出现意外类型

我在 PyCharm 中有以下代码:

LOCATIONS = {'loc1': [a, b, c], 'loc2': [d, e], 'loc3': [f, g]}
labels = ['loc2', 'loc3']
task_locations = dict(filter(lambda location: location[0] in labels, LOCATIONS.items()))
Run Code Online (Sandbox Code Playgroud)

PyCharm 发出以下警告filter(lambda location: location[0] in labels, LOCATIONS.items())

Unexpected type(s):
(Iterator[str])
Possible types:
(Mapping)
(Iterable[Tuple[Any, Any]])
Run Code Online (Sandbox Code Playgroud)

我应该如何针对警告采取行动?相同的表达式,但在Dict[str, int], 上没有警告。LOCATIONS所以我想这与a有关Dict[str, List[str]]

python pycharm

4
推荐指数
1
解决办法
3386
查看次数

标签 统计

java ×1

pycharm ×1

python ×1

spring-boot ×1

thymeleaf ×1