我有页面
getRootRequestMapperAsCompound().add(new NoVersionMapper("/card/${cardId}", CardPage.class));.
在此页面上有TinyMCE4编辑器。哪个尝试使用相对路径“images / 1.jpg”加载图像 我已添加资源映射以允许成功加载图像。
mountResource("/card/image/${imageId}", imageResourceReference);
在开发模式下一切正常,图像被加载到编辑器中,但在部署模式下,Page已被调用两次,第一次调用/ card / 1,第二次调用/card/image/1.jpg.
如何为DEPLOYMENT模式正确安装资源?
更新看起来像找到原因
public int getCompatibilityScore(Request request)
{
return 0; // pages always have priority over resources
}
,但问题是:“为什么它在开发模式下运行良好”?
更新2 我找不到更好的解决方案然后添加我自己的资源映射器并覆盖getCompatibilityScore()
public class ImageResourceMapper extends ResourceMapper {
private String[] mountSegments;
public ImageResourceMapper(String path, ResourceReference resourceReference) {
super(path, resourceReference);
mountSegments = getMountSegments(path);
}
public ImageResourceMapper(String path, ResourceReference resourceReference, IPageParametersEncoder encoder) {
super(path, resourceReference, encoder);
mountSegments = getMountSegments(path);
}
@Override
public int getCompatibilityScore(Request request) {
if (urlStartsWith(request.getUrl(), mountSegments)) {
return 10;
}
return 0;
}
}