java - 在 vaadin 10 spring boot 应用程序中放置样式表的位置

标签 java css spring spring-boot vaadin10

我正在使用 spring boot 测试 vaadin 10 应用程序。我用了 https://start.spring.io/生成一个元素。我遵循了 vaadin 的文档 https://vaadin.com/docs/v10/flow/importing-dependencies/tutorial-include-css.html .有以下说明:“您可以将样式表和其他静态资源放在 WAR 文件内的任何文件夹中,但/VAADIN 保留供框架内部使用。如果您已将其映射到/,VaadinServlet 将处理静态资源请求。否则, servlet 容器将处理静态资源请求。”

我创建了一个样式表 style.css 并将其放在我的 spring boot 应用程序的 resources 文件夹下。我使用@StyleSheet("style.css") 在我的类中引用了样式表。我也设置了 div 的类名。但是当我运行应用程序时,我的样式表似乎没有被使用。放置样式表的正确方法是什么?

@StyleSheet("style.css")
public class MainView extends VerticalLayout {
    private TextField filter;
    private Button addNewBtn;

    public MainView() {
        TestDiv testDiv = new TestDiv();

        add(testDiv);
    }

    public class TestDiv extends Div {

        public TestDiv() {
            setText("TestDiv");
            setClassName("custom-cell");
        }

    }
}

最佳答案

如果你打包成WAR,src/main/resources/static/frontend/,

如果 JAR: src/main/resources/META-INF/resources/frontend/

关于java - 在 vaadin 10 spring boot 应用程序中放置样式表的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52546959/

相关文章:

java - 我收到错误::org.apache.poi.openxml4j.exceptions.InvalidFormatException 无法解析

html - 在 bootstrap 中列出带有背景颜色的链接项的组

javascript 和 html 红绿灯不工作

java - 使用 lucene IndexWriter 进行多线程处理

java - Jackson 相当于 XStreamImplicit

java - 我可以在服务 bean 中拥有公共(public)静态字段吗?

java - 在 Spring 中读取 2 个具有相同变量名的属性文件

java - 使用 Spring CrudRepository 的 Hibernate LazyInitializationException

java - 使用 wsdl2code 通过 WSDL 连接 web 服务抛出 java.net.MalformedURLException : Protocol not found:

javascript - 单击时变大的小图 block