Liferay,在期刊文章velocity模板中使用serviceLocator

Liferay,在期刊文章velocity模板中使用serviceLocator,liferay,velocity,Liferay,Velocity,我正在尝试在Liferay中的期刊文章的velocity模板中使用serviceLocator。 我通过添加以下行修改了portal-ext.properties文件: journal.template.velocity.restricted.variables= 然后我重新启动了服务器 在我的vm文件中,我有: #set ($countryService = $serviceLocator.findService("com.liferay.portal.service.CountryServ

我正在尝试在Liferay中的期刊文章的velocity模板中使用serviceLocator。 我通过添加以下行修改了portal-ext.properties文件:

journal.template.velocity.restricted.variables=
然后我重新启动了服务器

在我的vm文件中,我有:

#set ($countryService = $serviceLocator.findService("com.liferay.portal.service.CountryService"))
#set ($countryList = $countryService.getCountries())
#foreach ($country in $countryList)
    $country.getName()
#end
这不会在文章中显示任何内容,也不会在服务器上显示任何错误。我还检查了数据库和国家,如果我在Portlet服务中使用getCountries()方法,它会返回应该返回的国家


有人有过类似的问题吗?

我发现我做错了什么。 在portal-ext.properties中,我首先设置:

journal.template.velocity.restricted.variables=
但相反,它应该是:

velocity.engine.restricted.variables=