gpt4 book ai didi

java - 从 portlet 将图像上传到 liferay 主题

转载 作者:行者123 更新时间:2023-11-29 04:59:41 25 4
gpt4 key购买 nike

我有 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可以是renderRequestactionRequest

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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com