在Struts 2和JSP中使用带有多个参数的getText()

时间:2014-01-10 16:48:12

标签: jsp struts2 properties-file dynamic-variables

我正在使用JSP开发Struts2框架。我有 *。properties 文件:

hover_remove=Remove access to {0} at {1}`

我的JSP中有一个提交标记:

title="%{getText('hover_remove', new String[]{{appLabel}, {locationLabel}})}"

可以在Java中工作,但我在JSP中遇到以下错误:

/WEB-INF/pages/admin/cm/view.jsp(9,287) 
JSPG0055E: Unable to create an xml attribute from name


在JSP中使用getText(String, List String[])的任何提示?

1 个答案:

答案 0 :(得分:3)

如果你想创建String-s数组,那么你需要为类使用FQN并删除不需要的大括号。

title="%{getText('hover_remove', new java.lang.String[]{appLabel, locationLabel})}"

但是您可以使用getText方法接受List作为第二个参数,并利用OGNL列表创建功能。在OGNL中创建一个列表,你需要简单地将一个表达式列表放在花括号中。

title="%{getText('hover_remove', {appLabel, locationLabel})}"
相关问题