一般用plugin开发portlet,使用资源文件的方法是:
struts-config.xml:
<message-resources parameter="content.Language"></message-resources>
portlet.properties:
language.bundle=content.Language
然后就可以在页面中使用
<liferay-ui:message key="key-value" /> 取得在language.properties中定义的值,
但是在这次的portlet中怎么也取不到,不知道是什么原因,超级郁闷……
换了一种方式:
还是在portlet.properties中定义:
language.bundle=content.Language
在页面中:
<%
Locale locale1 = (Locale)session.getAttribute("org.apache.struts.action.LOCALE");
ResourceBundle bundle = ResourceBundle.getBundle("content.Language-ext_zh_CN", locale1);
%>
获得bundle对象,然后用
bundle.getString(" key-value");
就可以取到资源文件的内容了。
还没弄明白怎么覆盖liferay中portal-impl.jar中的语言文件。