Vaadin 10没有在Spring-Boot中使用模板

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Vaadin 10没有在Spring-Boot中使用模板相关的知识,希望对你有一定的参考价值。

我试图在Spring-Boot应用程序中使用Vaadin 10的模板。

问题是,显示页面时不使用模板。页面上没有出现模板的任何组件。

我的模板PersonForm.html存储在src/main/resources/META-INF/resources/frontend/src中。

试图绑定它们的类是:

@Route
@Tag("person-form")
@HtmlImport("frontend://src/PersonForm.html")
public class PersonView extends VerticalLayout implements HasUrlParameter<String> {  

    public PersonView() {}

    @Override
    public void setParameter(BeforeEvent event, String parameter) {}
}
答案

将模板放在src/main/resources/META-INF/resources/frontend中是正确的。对于Spring-Boot,至少这是默认文件夹。

问题是,正在使用模板的类必须扩展PolymerTemplate<TemplateModel>

您可以使用自己的模型代替TemplateModel

这将有效:

@Tag("person-form")
@HtmlImport("frontend://src/PersonForm.html")
public class PersonView extends PolymerTemplate<TemplateModel> implements HasUrlParameter<String> {

Documentation

以上是关于Vaadin 10没有在Spring-Boot中使用模板的主要内容,如果未能解决你的问题,请参考以下文章