๋ฐฑ์๋51 Spring MVC ํ๋ก์ ํธ์ ๊ธฐ๋ณธ๊ตฌ์กฐ www.iotworks.co.kr/xe/index.php?mid=JSP&document_srl=53855 2021. 4. 27. ์คํ๋ง ํ๋ ์์ํฌ - ๋ก๊ทธ (Log4j) ๋ฐ ์ธํฐ์ ํฐ (Interceptor) ์ค์ ๋ฒ 1. Log4j ์ค์ Log4j๋ ์๋ฐ๊ธฐ๋ฐ์ ๋ก๊น ์ ํธ๋ฆฌํฐ๋ก, Apache์์ ๋ง๋ ์คํ์์ค ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค. ๊ฐ์๊ธฐ ๋ก๊ทธ๋ผ๊ณ ํ๋ฉด ์ด๊ฒ ๋ฌด์์ธ๊ฐ, ๊ทธ๊ฑธ ๋์ฒด ์ด๋ฐ ์จ๋จน๋๊ฒ์ธ๊ฐ!!!! ๋ผ๊ณ ์๊ฐํ ์ ์์ง๋ง, ๋ก๊ทธ๋ ์ฐ๋ฆฌ๊ฐ ๊ต์ฅํ ๋ง์ด ์ฐ๊ณ ์๋ค. ์๋ฅผ ๋ค์ด์, ๊ฐ๋ฐ์ ํ๋ค๊ฐ ์ด๋ค ๋ณ์์ ๊ฐ์ ํ์ธํ๊ณ ์ถ์ผ๋ฉด ์์ฐ์ค๋ฝ๊ฒ System.out.println()์ผ๋ก ์ถ๋ ฅ์ ํ๋๋ฐ, ์ด๋ฐ๊ฒ๋ค์ด ๋ชจ๋ ๋ก๊ทธ์ ํ ์ข ๋ฅ๋ผ๊ณ ์๊ฐํ ์ ์๋ค. ๊ทธ๋ฌ๋ฉด ๊ทธ๋ฅ System.out.println()์ผ๋ก ์ถ๋ ฅํ๋ฉด ๋๋๋ฐ ์ ๊ท์ฐฎ๊ฒ ๋ค๋ฅธ๊ฑธ ์ฌ์ฉํ๋๋ ์๋ฌธ์ด ๋ค ์ ์๋ค. ์ฌ์ค ์ฐ๋ฆฌ๊ฐ ํผ์์ ๊ทธ๋ฅ ์ฐ์ต์ผ์ ํ๋ก์ ํธ๋ฅผ ๋ง๋ค๊ฑฐ๋ ํ๋ฉด System.out.println()์ ํฐ ๋ฌธ์ ๊ฐ ์์ง๋ง, ์ค์ ํ๋ก์ ํธ๋ ํผ์์ ํ๋๊ฒ๋ ์๋๊ณ , ๋ .. 2021. 4. 27. ์คํ๋ง ํ๋ ์์ํฌ - ๊ฐ ๋๊ธฐ๊ธฐ ๊ธฐ๋ณธ index.jsp Hello Spring hello๋ก ์ด๋ home์ผ๋ก์ด๋ home.jsp home.jsp ์ด๋ฆ: ์ด๋ฆ:${_name } ์ด๋ฆ์ ๋ ฅ: ๋์ด์ ๋ ฅ: world๋ก ์ด๋ dispatcherServlet.xml HelloController.java package bit.com.a; import java.util.Date; import org.slf4j.Logger; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.ann.. 2021. 4. 19. ์คํ๋ง ํ๋ ์์ํฌ - Model ๊ฐ์ฒด Spring Model ๊ฐ์ฒด Controller์ ๋ฉ์๋๋ Model์ด๋ผ๋ ํ์ ์ ๊ฐ์ฒด๋ฅผ ํ๋ผ๋ฏธํฐ๋ก ๋ฐ์ ์ ์๋ค. ์์ํ๊ฒ JSP Servlet์ผ๋ก ์น ์ดํ๋ฆฌ์ผ์ด์ ์ ๋ง๋ค ๋ ๋ณดํต request๋ session ๋ด์ฅ๊ฐ์ฒด์ ์ ๋ณด๋ฅผ ๋ด์ jsp์ ๋๊ฒจ์ฃผ๊ณค ํ๋๋ฐ Spring์์๋ Model์ด๋ผ๋ ๋ ์์ ์ด๋ค. ์ฆ request.setAttribute() ์ ๋น์ทํ ์ญํ ์ ํ๋ ๊ฒ. request.setAttribute("time", new java.util.Date()); RequestDispatcher dispatcher = request.getRequestDispatcher("url"); dispatcher.forward(request, response); ์ ์ฝ๋๋ jsp๋ก ๊ฒ์ํ์ ๋ง๋ค๋ ๋ง์ด ์ฌ์ฉ.. 2021. 4. 19. ์ด์ 1 2 3 4 5 6 ยทยทยท 13 ๋ค์