- request parameter 를 GET 방식의 query string 이 아닌 URL 경로에 담아서 전달하는 방법
- 예제 코드
HomeController.java
// ---------------------------------------------------
// @ParamVariable 사용
@RequestMapping("/board/writePath/{name}/{subject}/{content}")
public String writePathBoard(
Model model,
@PathVariable String name,
@PathVariable String subject,
@PathVariable String content
) {
model.addAttribute("name", name);
model.addAttribute("subject", subject);
model.addAttribute("content", content);
return "board/writepath";
}
writepath.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
작성자: ${name}<br>
글제목: ${subject}<br>
내용: ${content}<br>
<button onclick="history.back()">이전으로</button>
'웹개발 > Spring' 카테고리의 다른 글
redirect, RedirectAttributes (0) | 2021.11.29 |
---|---|
Servlet, JSP, JavaScript, Spring의 redirect, forward 총정리 (0) | 2021.11.29 |
Binding, BindException (0) | 2021.11.29 |
스프링 부트 (0) | 2021.11.26 |
스프링의 핵심 (0) | 2021.11.26 |