我已经编码了该控制器方法的实现:
@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
的路径参数是null
。
有什么想法吗?
答案 0 :(得分:2)
您缺少@PathVariable
@RequestMapping(value = "/userlogin4download/{id}", method = RequestMethod.GET)
@Override
public void downloadAfterGicar(HttpServletRequest request,
HttpServletResponse response,
@PathVariable("id") String id) throws IOException {
LOG.info("Requested URI: " + request.getRequestURI());
LOG.info("{id} path param: " + id);
// other code
}