我有Liferay Spring Maven portlet和liferay主题。现在,用户将通过portlet上传图像。我们如何将其放置在/ webapps / theme / images中?是否有任何内置的liferay功能/ API可以帮助我们将上传的图像放置到主题中?

最佳答案

有关文件上传功能,您可以参考:
How to upload file in relative directory

对于主题图像文件夹的动态路径,可以通过ThemeDisplay对象获取它,如下所示:

行动:

ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
String themeImagePath = themeDisplay.getPortalURL() + themeDisplay.getPathImage();


其中request可以是renderRequestactionRequest

JSP:

<liferay-theme:defineObjects />

String themeImagePath = themeDisplay.getPortalURL() + themeDisplay.getPathImage();


其他相对使用的选项是themeDisplay().getPathThemeCss()themeDisplay().getPathJavaScript()themeDisplay().getPathMain()

07-24 09:46
查看更多