Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring启动:路径参数为空_Spring_Spring Boot - Fatal编程技术网

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
注释。对不起,我以为它是自动映射的。对不起,我以为它是自动映射的。