Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 588
user3179271 Avatar asked Oct 01 '22 22:10

user3179271


1 Answers

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})}"
like image 57
Aleksandr M Avatar answered Oct 05 '22 12:10

Aleksandr M