springmvc中controller方法参数接受问题

@Controller
public class MyController {
@RequestMapping("/user2")
public ModelAndView user2(Integer id) {
ModelAndView view = new ModelAndView();
view.setViewName("/index.jsp");
System.out.println(id);
return view;
}
}
jsp中:


为什么表单中传的id,后台打印的值为null

值没传过去,你检查一下值是否传送了

表单

接收
int id = Integer.parseInt(request.getParamter("id"));

调式看看是不是真的传过来了,注意大小写和类型