Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从portlet将图像上载到liferay主题_Java_Spring_Liferay_Liferay Theme - Fatal编程技术网

Java 从portlet将图像上载到liferay主题

Java 从portlet将图像上载到liferay主题,java,spring,liferay,liferay-theme,Java,Spring,Liferay,Liferay Theme,我有Liferay Spring Maven portlet和Liferay主题。现在,用户将通过portlet上传一个图像。我们如何将其放置在/webapps/theme/images中?是否有任何内置liferay功能/API可以帮助我们将上传的图像放入主题?有关文件上传功能,您可以参考: 对于主题的图像文件夹的动态路径,您可以通过ThemeDisplay对象获取,如下所示: 行动: ThemeDisplay themeDisplay = (ThemeDisplay) request.ge

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

有关文件上传功能,您可以参考:

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

行动:

ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);    
String themeImagePath = themeDisplay.getPortalURL() + themeDisplay.getPathImage();
<liferay-theme:defineObjects />

String themeImagePath = themeDisplay.getPortalURL() + themeDisplay.getPathImage();
其中,
request
可以是
renderRequest
actionRequest

JSP:

ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);    
String themeImagePath = themeDisplay.getPortalURL() + themeDisplay.getPathImage();
<liferay-theme:defineObjects />

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

字符串themeImagePath=themeDisplay.getPortalURL()+themeDisplay.getPathImage();

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

@Kumar,我们首先要怎么上传?你可以做File folder=new File(themeImagePath);就像这样。我放弃了将图片上传到主题的想法,因为下次我们发布新版本时,上传的数据将丢失。相反,我将上传图像到文件系统上的一个目录,并从那里读取它。感谢您的回复。关于“如何在相对目录中上载文件”的回答揭示了如何将图像上载到本地目录。我永远不会更改主题中的文件。如果你的主题在一个WAR文件中呢?那么缓存呢(通常图像形成一个WAR,缓存在浏览器中)?那么安全呢?你可以将图像上传到“文档和媒体”中,并将其包含在主题中——这将更容易实现…@Tobian我放弃了将图像上传到主题的想法,因为下次我们发布新版本时,上传的数据将丢失。相反,我将把图像上传到文件系统的一个目录中,并从那里读取。Veeru a S,至于你的问题,我的答案已经满足了你的要求。如果答案符合你的要求,你应该接受它,这样你就可以相信它对其他人也有帮助。