Html ApacheWicket-使用http URL作为src添加图像
我正在尝试将img标记添加到wicket页面。我没有图像作为文件,我有它的URL。我使用页面构造函数中使用的REST服务检索URL 我尝试了以下代码,但没有成功(我遇到了一个找不到标记文件关联的异常): 有人能帮我吗 谢谢Html ApacheWicket-使用http URL作为src添加图像,html,image,wicket,Html,Image,Wicket,我正在尝试将img标记添加到wicket页面。我没有图像作为文件,我有它的URL。我使用页面构造函数中使用的REST服务检索URL 我尝试了以下代码,但没有成功(我遇到了一个找不到标记文件关联的异常): 有人能帮我吗 谢谢 Laura您只需使用WebmarkupContainer即可: image = new WebMarkupContainer("chart-img") { protected void onComponentTag(final ComponentTag tag) {
Laura您只需使用WebmarkupContainer即可:
image = new WebMarkupContainer("chart-img") {
protected void onComponentTag(final ComponentTag tag)
{
super.onComponentTag(tag);
tag.put("src", url);
tag.put("title", title);
}
};
add(image)
你也可以试试这个
Image image = new Image("chart-img", "");
image.add(new AttributeModifier("src", url);
image.add(new AttributeModifier("title", title);
add(image);
一段时间以来,也有
org.apache.wicket.markup.html.image.ExternalImage
专门用于此用例
Image image = new Image("chart-img", "");
image.add(new AttributeModifier("src", url);
image.add(new AttributeModifier("title", title);
add(image);