2

我要实现这样的 ${context:layout/images/${itemProperty.signImage}.png}。但我收到以下错误

Could not convert 'context:layout/images/${itemProperty.signImage' into a component parameter binding: Unable to locate asset 'context:layout/images/${itemProperty.signImage' (the file does not exist). [at classpath:net/web/app/sample/pages/Test.tml, line 30].

请任何人说我该如何实现。

4

1 回答 1

3

您不能在上下文表达式中使用表达式。但是您可以通过AssetSource服务获取资产:

@Inject
private AssetSource assetSource;

public Asset getSignImage() {
    final String path = "layout/images/" + itemProperty.getSignImage() + ".png";
    return assetSource.getContextAsset(path, null);
}
于 2013-06-08T15:44:19.657 回答