简体   繁体   English

Liferay 7.1 - 如何为 pdf 文件添加链接 html

[英]Liferay 7.1 - How to add a link html for a pdf file

I have a main module C-portlet that contains in the folder resources a pdf file.我有一个主模块 C-portlet,它在文件夹资源中包含一个 pdf 文件。

resources/webapp/files/cg.pdf

I have a war theme.我有一个战争主题。 In one of its jsp page, i need to add a link for the cg.pdf.在其中一个 jsp 页面中,我需要为 cg.pdf 添加一个链接。

For now, i have :现在,我有:

<a target="_blank" href="/o/Cportlet/src/main/resources/META-INF/resources/webapp/files/cg.pdf"><liferay-ui:message key="cg-link"/></a>

but it doesn't work.但它不起作用。

Last point, this pdf could be changed at anytime without a deploy again a module / war.最后一点,这个 pdf 可以随时更改,无需再次部署模块/战争。

Is anyone have an idea ?有人有想法吗?

Thanks谢谢

You can put your pdf file in one of your theme resource folders (for example the "templates" folder).您可以将您的 pdf 文件放在您的主题资源文件夹之一(例如“模板”文件夹)。

Now you can use themeDisplay.getPathThemeTemplates() + "/cg.pdf" or within your theme with freemarker "${templates_folder}/cg.pdf"现在您可以使用themeDisplay.getPathThemeTemplates() + "/cg.pdf"或在您的主题中使用 freemarker "${templates_folder}/cg.pdf"

There are several ways to do this: imagining you cannot use the regular documents library... Or you module cannot use the library to get resources..有几种方法可以做到这一点:想象你不能使用常规文档库......或者你的模块无法使用该库来获取资源......

You could use a resource action if you have an MVC portlet.如果您有 MVC portlet,则可以使用资源操作。 This would be the simplest way to just serve that resource, and you would only need to put the MVC resource command URL in you jsp.这将是仅提供该资源的最简单方法,您只需将 MVC 资源命令 URL 放入您的 jsp 中。 Regular portlets can also provide resources but not as easily.常规 portlet 也可以提供资源,但不是那么容易。

For general modules you can create a struts action..which are normally way more complicated, especially if the resource is for private use only.对于一般模块,您可以创建一个 struts 操作……这通常更复杂,尤其是当资源仅供私人使用时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM