1
我無法將圖像添加到位於my/webapp/images /目錄中的我的列表視圖中。列表視圖中的Wicket IPackageResourceGuard圖像
ListView<Games> gamesList = new ListView<Games>("gamesList", games) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<Games> item) {
Games game = item.getModel().getObject();
item.add(new Image("champImage", "hello").add(new AttributeModifier("src", "dorans.png")));
item.add(new Image("enemyChampImage", "world").add(new AttributeModifier("src", "dorans.png")));
item.add(new Label("champName", game.getChampName()));
item.add(new Label("enemyChampName", game.getEnemyChampName()));
item.add(new Label("goldSpent", game.getGoldSpent()));
item.add(new Image("item0", "name1").add(new AttributeModifier("src", "dorans.png")));
item.add(new Image("item1", "name2").add(new AttributeModifier("src", "dorans.png")));
item.add(new Image("item2", "name3").add(new AttributeModifier("src", "dorans.png")));
item.add(new Image("item3", "name4").add(new AttributeModifier("src", "dorans.png")));
item.add(new Image("item4", "name5").add(new AttributeModifier("src", "dorans.png")));
item.add(new Image("item5", "name6").add(new AttributeModifier("src", "dorans.png")));
item.add(new Image("item6", "name7").add(new AttributeModifier("src", "dorans.png")));
}
};
我看網上說檢票(版本號)增加了一個IPackageResourceGuard所以不需要的文件不被訪問,所以我說這個我WicketApplication.java。
@Override
public void init()
{
super.init();
// add your configuration here
IPackageResourceGuard packageResourceGuard = this.getResourceSettings().getPackageResourceGuard();
if (packageResourceGuard instanceof SecurePackageResourceGuard) {
SecurePackageResourceGuard guard = (SecurePackageResourceGuard) packageResourceGuard;
guard.addPattern("+*.png");
}
}
這是爲了允許使用.png,但我仍然得到異常!
Caused by: org.apache.wicket.request.resource.PackageResource$PackageResourceBlockedException: Access denied to (static) package resource com/riot/itemsets/hello. See IPackageResourceGuard
at org.apache.wicket.request.resource.PackageResource.internalGetResourceStream(PackageResource.java:490) ~[wicket-core-7.0.0.jar:7.0.0]
at org.apache.wicket.request.resource.PackageResource.getResourceStream(PackageResource.java:440) ~[wicket-core-7.0.0.jar:7.0.0]
at org.apache.wicket.request.resource.PackageResource.getCacheKey(PackageResource.java:258) ~[wicket-core-7.0.0.jar:7.0.0]
at org.apache.wicket.request.resource.caching.version.RequestCycleCachedResourceVersion.getVersion(RequestCycleCachedResourceVersion.java:82) ~[wicket-core-7.0.0.jar:7.0.0]
at org.apache.wicket.request.resource.caching.FilenameWithVersionResourceCachingStrategy.decorateUrl(FilenameWithVersionResourceCachingStrategy.java:105) ~[wicket-core-7.0.0.jar:7.0.0]
at org.apache.wicket.core.request.mapper.BasicResourceReferenceMapper.mapHandler(BasicResourceReferenceMapper.java:240) ~[wicket-core-7.0.0.jar:7.0.0]
at org.apache.wicket.request.mapper.ParentPathReferenceRewriter.mapHandler(ParentPathReferenceRewriter.java:91) ~[wicket-request-7.0.0.jar:7.0.0]
at org.apache.wicket.request.mapper.CompoundRequestMapper.mapHandler(CompoundRequestMapper.java:213) ~[wicket-request-7.0.0.jar:7.0.0]
at org.apache.wicket.request.cycle.RequestCycle.mapUrlFor(RequestCycle.java:434) ~[wicket-core-7.0.0.jar:7.0.0]
at org.apache.wicket.request.cycle.RequestCycle.urlFor(RequestCycle.java:534) ~[wicket-core-7.0.0.jar:7.0.0]
... 108 more
似乎圖像構造函數是錯誤的。看圖像的例子。 –