How to add static resources to vaadin

微笑、不失礼 提交于 2019-12-08 05:47:16

问题


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

I have tried putting them nearly everywhere (WEB-INF, WEB-INF/classes, VAADIN, VAADIN/themes/.., etc) but they remain unaccessible.

How can I add static images to my vaadin application so they can be accessed by css?

UPDATE

Note that the images need to be accessible by css in the form of:

.myCssClass {
    background: url(path/to/image.png);
}

回答1:


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");


来源:https://stackoverflow.com/questions/24364251/how-to-add-static-resources-to-vaadin

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!