사용자가 레코드를 데이터베이스에 삽입하면 동시에 새 레코드를 만들고 새로운 버튼을 클릭 할 수있는 양식이 있습니다. 이 명령을 받아들이고 목록 상자가 채워진 채로 빈보기 만 사용자에게 반환하도록 컨트롤러를 정의했습니다. 그러나 뷰가 비어 있지 않으면 데이터베이스에 이전 삽입의 데이터가 있습니다.스프링 MVC 사용자에게 빈보기 반환
코드 :
사용자는 다음과 같은 버튼
<button class="btn" value="new" onclick="submitPage('${pageContext.request.contextPath}/crime_registration_new.htm');" type="button" >New</button>
컨트롤러 방법을 선택합니다
내가 이전 범죄의 객체를 제거하려는@RequestMapping(value="crime_registration_new.htm", method = RequestMethod.POST)
public ModelAndView loadNew(HttpServletRequest request,
HttpServletResponse response,
@ModelAttribute Crime crime,
Model model) throws Exception {
try{
logger.debug("In Crime Registration Controller");
myCriminalList.put("dbcriminalList", this.citizenManager.getListOfCriminals());
myVictimList.put("dbvictimList", this.citizenManager.getListOfVictims());
myStatusList.put("statusList", this.statusManager.getStatusList());
myCrimeCategoryList.put("crimeCategoryList", this.crimeCategoryManager.getCrimeCategoryList());
myCrimeLevelList.put("crimeLevelList", this.crimeLevelManager.getCrimeLevelList());
myOfficerList.put("investigatingOfficerList", this.officerManager.getOfficersList());
model.addAttribute("dbcriminals", myCriminalList);
model.addAttribute("dbvictims", myVictimList);
model.addAttribute("status", myStatusList);
model.addAttribute("crimeCategory", myCrimeCategoryList);
model.addAttribute("crimeLevel",myCrimeLevelList);
model.addAttribute("officers",myOfficerList);
model.addAttribute("crimeRecordNoStatus", "true");
model.addAttribute("crimeRecordNoStatus", "true");
model.addAttribute("save", "enabled");
return new ModelAndView("crime_registration");
}catch(Exception e){
logger.debug("Exception In CrimeRegistration Controller : " + e.getMessage());
return new ModelAndView("crime_registration");
}
}