我有 Liferay Spring Maven portlet 和 liferay 主题。现在用户将通过 portlet 上传图像。我们如何将它放在/webapps/theme/images 中?任何内置的 liferay 功能/API 可以帮助我们将上传的图像放入主题中?
最佳答案
文件上传功能可以引用: How to upload file in relative directory
主题图片文件夹的动态路径,可以通过ThemeDisplay
对象获取,如下:
Action :
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
String themeImagePath = themeDisplay.getPortalURL() + themeDisplay.getPathImage();
其中request
可以是renderRequest
或actionRequest
。
JSP:
<liferay-theme:defineObjects />
String themeImagePath = themeDisplay.getPortalURL() + themeDisplay.getPathImage();
其他比较常用的选项有themeDisplay().getPathThemeCss()
, themeDisplay().getPathJavaScript()
或者themeDisplay().getPathMain()
;
关于java - 从 portlet 将图像上传到 liferay 主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32495283/