无法确定 Wicket 中背景图像的路径

Unable to determine path for background image in Wicket

我在 Wicket 6.x 中创建了一个简单的网页,其中也有一个背景图片。 着陆页 localhost:8080 在 html 文档中将 css 定义为:

    <style>
    html,body{
        background: url("bg.png");
    }
    </style>

bg.png 存储在 src/main/webapp 中,似乎工作正常。

但是一旦转到下一页,我在其中以相同的方式定义了 css,图像就不会显示。单击生成的 url,即 localhost:8080/wicket/bookmarkable/bg.png,页面显示 "resource not found"。

我的 css 资源应该放在哪里?正确的路径应该是什么?另外,我的 java class 文件中是否也需要执行任何方法或初始化?

使用“/bg.png”作为路径。这是上下文绝对路径,无论当前页面的 url 是什么都有效。