5

我正在使用 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


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

4

1 回答 1

4

如果要创建 String-s 数组,则需要对类使用 FQN 并删除不需要的大括号。

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

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

title="%{getText('hover_remove', {appLabel, locationLabel})}"
于 2014-01-13T10:14:18.500 回答