Spring启动:路径参数为空
我已经对控制器方法实现进行了编码:Spring启动:路径参数为空,spring,spring-boot,Spring,Spring Boot,我已经对控制器方法实现进行了编码: @RequestMapping( value = "/userlogin4download/{id}", method = RequestMethod.GET ) @Override public void downloadAfterGicar( HttpServletRequest request, HttpServletResponse response, String id ) throws IOException
@RequestMapping(
value = "/userlogin4download/{id}",
method = RequestMethod.GET
)
@Override
public void downloadAfterGicar(
HttpServletRequest request,
HttpServletResponse response,
String id
) throws IOException {
LOG.info("Requested URI: " + request.getRequestURI());
LOG.info("{id} path param: " + id);
// other code
}
这种方法是可以实现的。然而,日志:
Requested URI: /userlogin4download/cpd1-dc598036-f615-4200-b685-d24831fb9343
{id} path param: null
如您所见,id
path参数为null
有什么想法吗?您缺少
@PathVariable
@RequestMapping(value=“/userlogin4download/{id}”,method=RequestMethod.GET)
@凌驾
公共无效下载AfterGICAR(HttpServletRequest请求,
HttpServletResponse,
@PathVariable(“id”)字符串id)引发IOException{
LOG.info(“请求的URI:+request.getRequestURI());
LOG.info(“{id}path参数:”+id);
//其他代码
}
您缺少@PathVariable
@RequestMapping(value=“/userlogin4download/{id}”,method=RequestMethod.GET)
@凌驾
公共无效下载AfterGICAR(HttpServletRequest请求,
HttpServletResponse,
@PathVariable(“id”)字符串id)引发IOException{
LOG.info(“请求的URI:+request.getRequestURI());
LOG.info(“{id}path参数:”+id);
//其他代码
}
当然它是null
因为它不是路径参数,因为它缺少@PathVariable
注释。当然它是null
因为它不是路径参数,因为它缺少@PathVariable
注释。对不起,我以为它是自动映射的。对不起,我以为它是自动映射的。