CSS的背景图像未显示

发布于 2025-02-11 03:53:37 字数 1061 浏览 3 评论 0原文

我已经用Vaadin 14.8.0和Springboot写了Java WebApp。 当我将应用程序放置在生产模式下,并使用命令“ MVN Clean -Packafuction”创建一个战争文件,并将其部署在我的野生蝇上时,一切正常。我的CSS文件已读取并激活。 但是,找不到CSS文件中用于背景图像的路径。

"background-image: url("/META-INF/resources/img/zac-bromell-QwrTnOlWAmI-unsplash.jpg");"

如果我直接以URL输入路径:

"http://localhost:8080/planyoureplaylist-1.0-SNAPSHOT/META-INF/resources/img/zac-bromell-QwrTnOlWAmI-unsplash.jpg" 

我也找不到404。

我的CSS文件位于/frontend/styles下的根目录中。 我的图像文件可以在src/main/resources/meta-inf/resources/img/中找到。

我还与Winrar一起查看了我的战争档案。由于我注意到我在目录中找到了图像文件Web-Inf \ class \ Meta-Inf \ resources \ img,但在整个文件夹结构中不是我的CSS文件中。

令我惊讶的是,当我尚未通过外部野生蝇启动应用程序时,正常显示背景图像。

参考以下链接 https://github.com/vaadin/flow/flow/flow/sissues/11015 < /a>我知道这是vaadin的错误。但是,由于我在Vaadin 14.8.0上,因此应该使用14.6.2修复该错误,因此我不明白问题。

很乐意指出是否需要其他事情来解决问题。

关于帮助,我会很高兴。 提前致谢

I have written a Java WebApp with Vaadin 14.8.0 and SpringBoot.
When I put the application in production mode and create a war file with the command "mvn clean package -Pproduction" and deploy it on my Wildfly, everything works normally. My CSS files are read and also activated.
However, the path I use in the css file for the background image is not found.

"background-image: url("/META-INF/resources/img/zac-bromell-QwrTnOlWAmI-unsplash.jpg");"

If I enter the path directly as url:

"http://localhost:8080/planyoureplaylist-1.0-SNAPSHOT/META-INF/resources/img/zac-bromell-QwrTnOlWAmI-unsplash.jpg" 

I also get a 404 Not Found.

My css files are located in the root directory under ./frontend/styles.
My image files can be found in src/main/resources/META-INF/resources/img/.

I also looked at my WAR file with WINRAR. Since I notice that I find the image files in the directory WEB-INF\classes\META-INF\resources\img, but in the whole folder structure not my css files.

To my surprise the background image was displayed normally when I started the application not yet via an external wildfly.

In reference to the following link https://github.com/vaadin/flow/issues/11015 I understand that it is a bug of vaadin. However, since I am on Vaadin 14.8.0 and the bug should be fixed with 14.6.2 I do not understand the problem.

Gladly point out if something else is needed to solve the problem.

About help I would be very happy.
Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

苏辞 2025-02-18 03:53:37

meta-inf/resources中的文件发表在服务器根中,因此您的meta-inf/resources/img/zac-bromell-qwrtnolwami-unsplash.jpg文件可用在您的上下文root中,请IMG/ZAC-BROMELL-QWRTNOLWAMI-UNSPLASH.JPG。因此,您的背景映像CSS应该为“背景图像:url)

The files in META-INF/resources are published in the server root so your META-INF/resources/img/zac-bromell-QwrTnOlWAmI-unsplash.jpg file is available at img/zac-bromell-QwrTnOlWAmI-unsplash.jpg inside your context root. Your background image CSS should thus be "background-image: url("img/zac-bromell-QwrTnOlWAmI-unsplash.jpg");"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文