5

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?

informatik01
  • 16,038
  • 10
  • 74
  • 104
user3179271
  • 53
  • 1
  • 3
  • `String`? What string? `some_cool_package.String` or `java.lang.String`? Hint: there is hint in the question. :) – Aleksandr M Jan 10 '14 at 17:18
  • @AleksandrM thank you! It's showing the value now. However, instead of "Remove access to first at second" its showing "Remove access to [first] at [second]". Is it possible to remove the square brackets? When I test with just one: `"%{getText('hover_remove', {appLabel})}"` it shows correctly. – user3179271 Jan 10 '14 at 18:37

1 Answers1

5

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})}"
Aleksandr M
  • 24,264
  • 12
  • 69
  • 143