CSS的背景图像未显示
我已经用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文件中。
令我惊讶的是,当我尚未通过外部野生蝇启动应用程序时,正常显示背景图像。
很乐意指出是否需要其他事情来解决问题。
关于帮助,我会很高兴。 提前致谢
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
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 yourMETA-INF/resources/img/zac-bromell-QwrTnOlWAmI-unsplash.jpg
file is available atimg/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");"