如何将静态资源添加到vaadin [英] How to add static resources to vaadin
问题描述
我正在运行一个vaadin应用程序,并有一些css文件使用url()语法引用图像。
I am running a vaadin application and have some css files that reference images using "url()" syntax.
然而,图像不可用,而在服务器端则出现错误:
The images however are not available and on the server side you get the error:
rejecting published file request for file that has not been published
我尝试过将它们放入几乎无处不在(WEB-INF,WEB-INF / classes,VAADIN,VAADIN / themes / ..等),但它们仍然无法访问。
I have tried putting them nearly everywhere (WEB-INF, WEB-INF/classes, VAADIN, VAADIN/themes/.., etc) but they remain unaccessible.
如何添加静态图像到我的vaadin应用程序,以便可以通过CSS访问它们?
How can I add static images to my vaadin application so they can be accessed by css?
更新
请注意,css需要以下列形式访问图像:
Note that the images need to be accessible by css in the form of:
.myCssClass {
background: url(path/to/image.png);
}
推荐答案
你应该把它们放到 VAADIN / themes / mytheme / images /
并将主题名称设置为 mytheme
。他们设置主题的方式取决于你的Vaadin版本。
可以像这样访问资源:
You should put them to VAADIN/themes/mytheme/images/
and set the theme name to mytheme
. They way how you set theme depends on your Vaadin version.
Resources will be accessible like that:
new ThemeResource("images/my_image.png");
这篇关于如何将静态资源添加到vaadin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!