Using getText() with more than one parameter in Struts 2 and JSP

6.5k Views Asked by At

I am working on the Struts2 framework with JSP. I have in my *.properties file:

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

I have in my JSP, within a submit tag:

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

which would work in Java, but I'm getting the following error in JSP:

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


Any tips for using getText(String, List String[]) in JSP?

1

There are 1 best solutions below

1
On BEST ANSWER

If you want to create array of String-s then you need to use FQN for the class and remove not needed braces.

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

BUT you can use getText method which accepts List as the second argument and take advantage of OGNL list creation feature. In OGNL to create a list you need to simple put a list of expressions in curly braces.

title="%{getText('hover_remove', {appLabel, locationLabel})}"