diff --git a/src/main/java/egovframework/example/sample/web/EgovSampleController.java b/src/main/java/egovframework/example/sample/web/EgovSampleController.java index f07517a..c318d52 100644 --- a/src/main/java/egovframework/example/sample/web/EgovSampleController.java +++ b/src/main/java/egovframework/example/sample/web/EgovSampleController.java @@ -60,6 +60,10 @@ public String list(@ModelAttribute SampleVO sampleVO, Model model) throws Except public String detail(@ModelAttribute SampleVO sampleVO, @RequestParam String id, Model model) throws Exception { sampleVO.setId(id); SampleVO detail = this.sampleService.selectSample(sampleVO); + + // 현재 페이지 지정 + detail.setPageIndex(sampleVO.getPageIndex()); + model.addAttribute("sampleVO", detail); return "egovSampleRegister"; } @@ -79,12 +83,12 @@ public String add(@Valid @ModelAttribute SampleVO sampleVO, BindingResult bindin } @PostMapping("/sample/update") - public String update(@Valid @ModelAttribute SampleVO sampleVO, BindingResult bindingResult) throws Exception { + public String update(@Valid @ModelAttribute SampleVO sampleVO, BindingResult bindingResult, Model model) throws Exception { if (bindingResult.hasErrors()) { return "egovSampleRegister"; } this.sampleService.updateSample(sampleVO); - return "redirect:/"; + return this.list(sampleVO, model); } @PostMapping("/sample/delete") diff --git a/src/main/resources/templates/thymeleaf/egovSampleList.html b/src/main/resources/templates/thymeleaf/egovSampleList.html index b06acad..b4cfda9 100644 --- a/src/main/resources/templates/thymeleaf/egovSampleList.html +++ b/src/main/resources/templates/thymeleaf/egovSampleList.html @@ -51,7 +51,7 @@ } function sampleCreate() { - $(location).attr('href', contextPath + '/sample/add'); + $(location).attr('href', contextPath + '/sample/add?pageIndex=[[${sampleVO.getPageIndex()}]]'); } function sampleDetail(id) { @@ -77,6 +77,7 @@
@@ -85,13 +86,13 @@