Reputation: 3130
I came across this weird situation-
In my Jsp, I have
<form:hidden path="year"/>
<portlet:resourceURL id="image" var="imageURL">
<portlet:param name="year" value="${bean.year}" />
</portlet:resourceURL>
<img src="${imageURL}" alt="Image" />
In my controller I have a method
@ResourceMapping("image")
public void getImage(ResourceRequest request, ResourceResponse response,
@RequestParam("year") final int year){
//serve resource here
}
During execution,
NumberFormatException is thrown : Cannot convert string [] to int 2013,2013
I found the soultion is to change the portlet:param name
from year
to something else, as there is already a hidden variable named year, for some reason the parameter gets passed twice in the request and fails to convert the value.
I would like to know why same parameter name is not acceptable if anyone has more knowledge about this.
Thanks
Upvotes: 0
Views: 3778
Reputation: 206
The problem is probably in <form:hidden path="year"/>
. With that code you put parameter year to the request and with <portlet:param name="year" value="${bean.year}" />
you put another one parameter year to the request. Therefore, you get array of year parameters in your controller and it is not possible to convert to int.
According to the code snippet of your JSP, I guess that <form:hidden path="year"/>
is not necessary to use.
Upvotes: 1