์ธํ๋ฐ ๊น์ํ๋์ ์คํ๋ง MVC 1ํธ ๊ฐ์ ๋ด์ฉ์ ๋ฐํ์ผ๋ก ์์ฑํ ๊ธ์
๋๋ค. 1. HttpServletResponse HttpServletResponse๋ HTTP ์๋ต ๋ฉ์ธ์ง๋ฅผ ์์ฑํด์ฃผ๋ ํด๋์ค์ด๋ค. ์๋ต ๋ฉ์ธ์ง๋ฅผ ์ง์ ์์ฑํ๋๊ฑด ๋ฒ๊ฑฐ๋กญ๊ธฐ ๋๋ฌธ์, ์๋ต์ฝ๋์ ํค๋, ๋ฐ๋์ ๋ฃ์ ๊ฐ๋ค์ ๋ฃ์ด์ฃผ๋ฉด HttpServletResponse ๊ฐ์ฒด๊ฐ ์๋ต ๋ฉ์ธ์ง๋ฅผ ์์ฑํด์ค๋ค. @WebServlet(name = "responseHeaderServlet", urlPatterns = "/response-header") public class ResponseHeaderServlet extends HttpServlet { @Override protected void service(HttpServletRequest reques..
์ธํ๋ฐ ๊น์ํ๋์ ์คํ๋ง MVC 1ํธ ๊ฐ์ ๋ด์ฉ์ ๋ฐํ์ผ๋ก ์์ฑํ ๊ธ์
๋๋ค. 1. ์๋ธ๋ฆฟ ๋ฑ๋กํ๊ธฐ package hello.servlet; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.ServletComponentScan; @ServletComponentScan // ์๋ธ๋ฆฟ ์๋ ๋ฑ๋ก @SpringBootApplication public class ServletApplication { public static void main(String[] args) { S..
์ธํ๋ฐ ๊น์ํ๋์ ์คํ๋ง MVC 1ํธ ๊ฐ์ ๋ด์ฉ์ ๋ฐํ์ผ๋ก ์์ฑํ ๊ธ์
๋๋ค. ์ด์ ๊ธ์์ ํด๋ผ์ด์ธํธ์ ์์ฒญ์ ์ฒ๋ฆฌํด์ฃผ๋ ์น ์ ํ๋ฆฌ์ผ์ด์
์๋ฒ์ ๋ํด ์์ฃผ ๊ฐ๋จํ๊ฒ ์์๋ณด์๋ค. ๊ทธ๋ ๋ค๋ฉด ์น ์ ํ๋ฆฌ์ผ์ด์
์๋ฒ๋ ๋ฌด์จ ์ผ์ ํ ๊น? ํด๋ผ์ด์ธํธ๊ฐ ์๋์ ๊ฐ์ ์์ฒญ์ ๋ณด๋ด์๋ค๊ณ ์๊ฐํด๋ณด์. POST /save HTTP/1.1 Host: localhost:8080 Content-Type: application/x-www-form-urlencoded username=kim&age=20 ๋์ถฉ ์ด๋ฆ์ด kim์ด๊ณ ๋์ด๊ฐ 20์ธ์ธ ํ์์ ์ ๋ณด๋ฅผ ๋ฑ๋กํด๋ฌ๋ผ๋ ์์ฒญ์ด๋ค. WAS๋ ์ด ์์ฒญ์ ์ฒ๋ฆฌํ๊ธฐ ์ํด ์๋์ ์
๋ฌด๋ค์ ์ ๋ถ ์ฒ๋ฆฌํด์ฃผ์ด์ผ ํ๋ค. ํด๋ผ์ด์ธํธ์์ ์์ผ ์ฐ๊ฒฐ HTTP ์์ฒญ ๋ฉ์ธ์ง ํ์ฑํด์ ์ฝ๊ธฐ ๋งคํ ์ ๋ณด ํ์ธ Cont..