我试图映射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注解?
如何正确使用它?