[spring] Required String parameter '인자' is not present 오류해결

뿌이·2022년 1월 20일
0

오류해결

목록 보기
11/49

업데이트 폼에서 post방식으로 /update로 넘어온 것을 dto 로 받은다음
sql에서 다 바뀌는데
redirect 해주는 과정에서 이러한 에러 메시지가 떴다.

문제해결

원인은 post /update에서 redirct 할 때에 get /update에서
id값이 없어서 그런거였음
그래서 model의 key 값으로 id넣어서 dto.getId()하게 했음
그랬더니 잘됨!

 @GetMapping("/update") 
		public String update(@RequestParam String id, Model model) {
			log.info("updateForm으로 이동...");
				model.addAttribute("list",service.getUserList(id));
				
			    return "/Book/mypageUpdateFrm";
		}
	 @PostMapping("/update") 
	 public String updateProc(UserDTO dto,Model model) {
		 log.info("post update/............"+dto);
		 service.update(dto);
		 
		 model.addAttribute("id",dto.getId());
		 return "redirect:/update";
	 }
profile
기록이 쌓이면 지식이 된다.

0개의 댓글