wicket图像路径无需重写

ogu*_*alb 1 url rewrite wicket image path

我试图上传和显示图像.我得到该文件,然后将其写入glassfish应用程序服务器的docroot

    Image image = new Image("myimage","images/task.gif");
Run Code Online (Sandbox Code Playgroud)

但我明白了 <img wicket:id="myimage" src="resources/wickcat.MyPage/images/task.gif" />

wicket有没有办法改写我的src路径?即使我使用http:// ....启动src,它也会写资源/ wickcat.MyPage/http:// ...这根本没有意义.我只需要写"images/task.gif".有任何想法吗?

Mar*_*elo 6

有两种方法可以做到这一点.

  1. 使用<img src="images/task.gif" />.这是因为您不需要引用类中的组件.

  2. 使用ContextImage image = new ContextImage("myimage", "images/task.gif");.如果使用ContextImage组件,源将相对于Context根,您甚至可以输入模型作为图像的相对路径.