RedirectView
view 페이지 강제 이동
( 페이지를 Redirect 시킴 )
( jsp 같은 얘들이 사용 )
정의
return new RedirectView("페이지경로");
JSP 예제
( 데이터 저장 후 페이지 강제 이동시키기 )
Controller
// TODO: 저장 클릭시 db 저장하기 함수
@PostMapping("경로")
public RedirectView create(@ModelAttribute 객체 객체변수) {
// TODO : 서비스의 저장함수
객체Service.save(객체변수);
return new RedirectView("페이지경로");
}
view
( form 입력양식 )
( BootStrap 사용 )
<form >
<div class="mb-3">
<label for="dname" class="form-label">부서 이름</label>
<input type="text" class="form-control" id="dname" required name="dname">
</div>
<div class="mb-3">
<label for="loc" class="form-label">부서 위치</label>
<input type="text" class="form-control" id="loc" required name="loc">
</div>
<div class="mb-3">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
'SpringBoot > code' 카테고리의 다른 글
SpringBoot - model / common package (0) | 2023.10.12 |
---|---|
SpringBoot - Optional (클래스) 예제 (1) | 2023.10.11 |
SpringBoot - @ResponseBody (1) | 2023.10.10 |
SpringBoot - model - 등록일 수정일 추가 (0) | 2023.10.10 |
SpringBoot - @Slf4j (0) | 2023.10.10 |