異常:
java.lang.IllegalStateException: Optional int parameter 'id' is present but cannot be translated into a null value due to being declared as a primitive type. Consider declaring it as object wrapper for the corresponding primitive type.
原因: 前臺傳的參數與處理參數不一致!
@RequestMapping("/del")
public String del(int id) {
//調用數據
int count= userinfoService.del(id);
return "redirect:/list"; //直接跳轉到所有頁面
}
解決:處理參數名稱不一致的情況,如果前臺傳入userId到後臺,可給該參數設置別名爲id
例如@RequestParam(value="userId") int id)
@RequestMapping("/del")
public String del(@RequestParam("userId") int id) {
//調用數據
int count= userinfoService.del(id);
return "redirect:/list"; //直接跳轉到所有頁面
}