SpringBoot-Missing URI template variable 'id' for method parameter of type String

原因:就是spring的controller上的@RequestMapping的实参和方法里面的形参名字不一致

前端:


          查看

错误写法1:

@RequestMapping(value="/allsee/{id}", method = {RequestMethod.GET})
public String SeeMilestone(HttpServletRequest request,@PathVariable String id) {
       return "milestone/see";
}

 错误写法2:

@RequestMapping(value="/allsee/{id}", method = {RequestMethod.GET})
public String SeeMilestone(HttpServletRequest request) {
       String id = request.getParameter("id");
       return "milestone/see";
}

正确写法:

@RequestMapping(value="/allsee", method = {RequestMethod.GET})
public String SeeMilestoneIndex(Model model,HttpServletRequest request) {
    	String id = request.getParameter("id");
}

 

你可能感兴趣的:(#,Thymeleaf,前端,#,SpringBoot,经验总结)