【发布时间】:2012-02-23 01:42:26
【问题描述】:
我正在尝试映射 url /locations/{locationId}/edit.html - 这似乎与此代码一起使用:
@Controller
@RequestMapping( "/locations" )
public class LocationController
{
@RequestMapping( value = "/{locationId}/edit.html", method = RequestMethod.GET )
public String showEditForm( Map<String, Object> map, @PathVariable int locationId )
{
map.put( "locationId", locationId );
return "locationform";
}
}
调用提到的url会导致异常:
java.lang.IllegalArgumentException: Name for argument type [int] not available, and parameter name information not found in class file either.
我是否以错误的方式使用了@PathVariable 注解?
如何正确使用?
【问题讨论】:
标签: java spring spring-mvc controller path-variables