Java Spring MVC和Liferay-资源映射问题
我遇到了这种奇怪的情况- 在我的Jsp中,我有Java Spring MVC和Liferay-资源映射问题,java,spring-mvc,liferay,spring-portlet-mvc,Java,Spring Mvc,Liferay,Spring Portlet Mvc,我遇到了这种奇怪的情况- 在我的Jsp中,我有 <form:hidden path="year"/> <portlet:resourceURL id="image" var="imageURL"> <portlet:param name="year" value="${bean.year}" /> </portlet:resourceURL> <img src="${imageURL}" alt="Image" />
<form:hidden path="year"/>
<portlet:resourceURL id="image" var="imageURL">
<portlet:param name="year" value="${bean.year}" />
</portlet:resourceURL>
<img src="${imageURL}" alt="Image" />
在执行期间
引发NumberFormatException:无法将字符串[]转换为int
20132013
我发现解决方法是将portlet:param name
从year
更改为其他内容,因为已经有一个名为year的隐藏变量,由于某种原因,该参数在请求中被传递了两次,并且无法转换值
我想知道,如果有人对此有更多的了解,为什么相同的参数名是不可接受的
谢谢问题可能出在
中。在该代码中,您将参数year添加到请求中,在
中,您将另一个参数year添加到请求中。因此,您在控制器中获得了年参数数组,无法转换为int
根据JSP的代码片段,我猜
是不需要使用的
@ResourceMapping("image")
public void getImage(ResourceRequest request, ResourceResponse response,
@RequestParam("year") final int year){
//serve resource here
}