简体   繁体   English

改变Wicket资源URL的URL前缀?

[英]Alter URL prefix for Wicket resource URLs?

Wicket automatically generates URLs to resources (images etc.) with the prefix "resources" (eg "http://localhost:8080/resources/org.apache.wicket.ajax.WicketAjaxReference/wicket-ajax.js"). Wicket自动生成带有前缀“resources”的资源(图像等)的URL(例如“http:// localhost:8080 / resources / org.apache.wicket.ajax.WicketAjaxReference / wicket-ajax.js”)。 Is it possible to change this prefix from "resources" to something else (like "res")? 是否可以将此前缀从“资源”更改为其他内容(如“res”)?

I have another servlet providing stuff under "resources" and I cannot change it (don't ask...), hence I would like Wicket to serve its resources with a different prefix. 我有另一个servlet提供“资源”下的东西,我不能改变它(不要问...),因此我希望Wicket使用不同的前缀来提供其资源。

Thanks! 谢谢!

This is not possible in Wicket 1.4, since the path is defined as the constant org.apache.wicket.protocol.http.request.WebRequestCodingStrategy.RESOURCES_PATH_PREFIX and is used hardcoded in the Wicket filter. 这在Wicket 1.4中是不可能的,因为路径被定义为常量org.apache.wicket.protocol.http.request.WebRequestCodingStrategy.RESOURCES_PATH_PREFIX并且在Wicket过滤器中使用硬编码。

In Wicket 1.5 it seems you have to override org.apache.wicket.Application.getEncoderContext() with an IMapperContext which returns your new prefix in getResourceIdentifier() . 在Wicket 1.5中,你似乎必须使用IMapperContext覆盖org.apache.wicket.Application.getEncoderContext() ,它在getResourceIdentifier()返回你的新前缀。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM