简体   繁体   English

如何在Liferay中为Portlet映射过滤器?

[英]How to map a filter for a portlet in Liferay?

I just created one filter inside my portlet and I want to execute it when one of the page inside my portlet is getting loaded. 我只是在portlet内创建了一个过滤器,并且想要在portlet内的页面之一被加载时执行它。

How can I map the filter for this requirement? 如何为此要求映射过滤器?

If you'd let us know what you want to achieve, someone might come up with a better way to implement this. 如果您让我们知道您想要实现的目标,那么有人可能会想出一种更好的方法来实现这一目标。 For now, you should bind your filter to /* and check for the expected URL yourself. 现在,您应该将过滤器绑定到/*并自己检查所需的URL。 Reasons: Liferay can show your page as /web/guest/my-page-name in the default language, /en/web/guest/my-page-name as an explicitly requested english page, /my-page-name when virtual hosting is enabled and the hosts match. 原因:Liferay可以以默认语言将页面显示为/web/guest/my-page-name ,将其显示为/en/web/guest/my-page-name作为显式请求的英文页面,将其/my-page-name虚拟时的/my-page-name托管已启用且主机匹配。

For some (maybe performance?) reasons servlet filter URLs must not start with wildcards, but can end in them. 出于某些(也许是性能?)原因,servlet过滤器URL不能以通配符开头,而可以以通配符结尾。 Thus you'll have to work with this limitations if a servlet filter is your tool of choice. 因此,如果选择servlet过滤器,则必须克服此限制。 As I said above, if we knew what you try to achieve, we might point out a better solution. 如前所述,如果我们知道您要实现的目标,我们可能会指出更好的解决方案。

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

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