Banner

My Tech Blog (Coding/Spring&JSP)

DB ์œ„์ฃผ๋กœ ํ• ๊ฑฐ๋ผ ํ™”๋ฉด์€ ๋ถ€ํŠธ์ŠคํŠธ๋žฉ์œผ๋กœ ํด๋ž˜์Šค๋งŒ ๋จน์—ฌ์„œ ๋งŒ๋“ค๊ณ  ์žˆ์–ด์š”. ๋ฐ์ดํ„ฐ ๋„˜์–ด๊ฐ€๋Š” ๊ฒƒ๋งŒ ๋ณผ ๊ฑฐ๋ผ์„œ ํ™”๋ฉด ๋””์ž์ธ์€ ์‹ ๊ฒฝ ๋ชป ์“ฐ๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค!! ์ด์˜๊ฒŒ ๋งŒ๋“ค๊ณ  ์‹ถ์€ ์‚ฌ๋žŒ์€ HTML/CSS ์‹ ๊ฒฝ์“ฐ๋ฉด์„œ ํ•˜์…”๋„ ์ข‹์Šต๋‹ˆ๋‹ค. ์ „ ๋ฐ”๋น ์„œ ๋””์ž์ธ์€ ๋ฒ„๋ ธ์ง€๋งŒ,  ์—ฌ๋Ÿฌ๋ถ„๋“ค์€ ์ด์˜๊ฒŒ ๋งŒ๋“œ์‹œ๋ผ๊ณ  ๊ฐ„๋‹จํ•œ ํšŒ์›๊ฐ€์ž…/๊ฒŒ์‹œํŒ ๋งŒ๋“ค๊ธฐ ์‹ค์Šตํ•ด ๋ณด์‹ค๋งŒํ•œ ๋ฌด๋ฃŒ ํ…œํ”Œ๋ฆฟ ์‚ฌ์ดํŠธ ๊ฐ€์ ธ์™”์Šต๋‹ˆ๋‹ค. ์ œ๊ฐ€  ์ถ”์ฒœํ•˜๋Š” ํ…œํ”Œ๋ฆฟ์€ Forty์ž…๋‹ˆ๋‹ค. Forty์—์„œ ํšŒ์›๊ฐ€์ž…/๋กœ๊ทธ์ธ/๊ฒŒ์‹œํŒ ๋“ฑ ์‹ค์Šตํ•˜์‹œ๊ธฐ ์ข‹์•„์š”. https://html5up.net/ HTML5 UPResponsive HTML5 and CSS3 site templates designed by @ajlkn and released under the Creative Commons license.ht..
Java Reousrces > user ์— UserDAO ํด๋ž˜์Šค ์ƒ์„ฑํ•˜๊ณ , JDBC ์—ฐ๋™์„ ํ•ด ์ค„ ๊ฒƒ์ด๋‹ค.DAO(Data Access Object) ํด๋ž˜์Šค๋Š” ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์™€ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ฐ„์˜ ์ƒํ˜ธ์ž‘์šฉ์„ ๋‹ด๋‹นํ•˜๋Š” ๊ฐ์ฒด. ์ฃผ๋กœ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์— ๋Œ€ํ•œ CRUD(Create, Read, Update, Delete) ์ž‘์—…์„ ์บก์Šํ™”ํ•˜๊ณ , ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๊ด€๋ จ ์ฝ”๋“œ๋ฅผ ๋ถ„๋ฆฌํ•˜์—ฌ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์œ ์ง€๋ณด์ˆ˜์„ฑ์„ ๋†’์ด๋Š” ๋ฐ ์‚ฌ์šฉ๋จ. 1. MySQL ์ ‘์†ํ•˜๊ธฐ ๋จผ์ € ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋˜๋Š” ์ฃผ์š” ๊ฐ์ฒด๋“ค `Connection conn`, `PreparedStatement`, `ResultSet` ๋ฅผ ์„ ์–ธ ํ•ด ์ฃผ์ž.             package user;public class UserDAO { // MySQL ์ ‘์†ํ•˜๊ธฐ..
์œˆ๋„์šฐํ‚ค > MYSQL Command Line Client MySQL ๊ณ„์ • ๋น„๋ฐ€๋ฒˆํ˜ธ ์ž…๋ ฅํ•œ ๋’คCREATE DATABASE BBS;USE BBS; BBS๋ผ๋Š”  ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค ๋งŒ๋“ค์–ด ์คŒ ์ด์ œ ํ…Œ์ด๋ธ” ์ƒ์„ฑํ•  ์ฐจ๋ก€ CREATE TABLE USER ๋กœ ์œ ์ € ์•„์ด๋””, ๋น„๋ฐ€๋ฒˆํ˜ธ, ์ด๋ฆ„, ์„ฑ๋ณ„, ์ด๋ฉ”์ผ ์ปฌ๋Ÿผ 5๊ฐœ ๋งŒ๋“ค์–ด ์ฃผ๊ณ  USERID๋ฅผ PK๋กœ ์ง€์ •ํ•ด์ฃผ์—ˆ์Œ.SHOW TABLES; ์œ„ ๋ช…๋ น์–ด๋กœ ํ…Œ์ด๋ธ” ๋ณด๊ธฐ  DESC USER; `DESC + ํ…Œ์ด๋ธ”๋ช…`์œผ๋กœ ํ˜„์žฌ ํ…Œ์ด๋ธ” ํ˜•ํƒœ ๋ณด์—ฌ์คŒ            ํ…Œ์ŠคํŠธ๋กœ ํ™๊ธธ๋™์ด๋ผ๋Š” ์œ ์ €์˜ ์ •๋ณด๋ฅผ ํ…Œ์ด๋ธ”์— ํ•œ ์ค„ ๋„ฃ์–ด ์คŒ ์ฐธ๊ณ ๋กœ ํ…Œ์ด๋ธ”์— ๋ฐ์ดํ„ฐ๊ฐ€ ์ž˜ ๋“ค์–ด๊ฐ”๋Š”์ง€ ํ™•์ธํ•˜๋ ค๋ฉด `select * from user;`  ๋ฐ์ดํ„ฐ๊ฐ€ ์ž˜ ๋“ค์–ด์™”์œผ๋ฉด `commit` ํ•ด ์ค€๋‹ค.  ์—ฌ๊ธฐ๊นŒ์ง€ ํ–ˆ์œผ๋ฉด ์ด์ œ..
๋ถ€ํŠธ ์ŠคํŠธ๋žฉ ๋‹ค์šด๋กœ๋“œ https://getbootstrap.com/docs/5.3/getting-started/download/ DownloadDownload Bootstrap to get the compiled CSS and JavaScript, source code, or include it with your favorite package managers like npm, RubyGems, and more.getbootstrap.com bootstrap-5.3.3-distํด๋” ์•ˆ์— ๋“ค์–ด๊ฐ€๋ฉด js๋ž‘ css ํด๋”๊ฐ€ ์žˆ๋‹ค.๋‘ ๊ฐœ ๋“œ๋ž˜๊ทธํ•˜๊ณ  ๋ณต์‚ฌํ•œ ํ›„ ์ดํด๋ฆฝ์Šค๋กœ ๋Œ์•„์™€์„œ  webapp์— ๋ถ™์—ฌ๋„ฃ๊ธฐ ํ•ด์„œ ์ถ”๊ฐ€  js๋Š” ์—‘์Šค ๋œจ๋Š”๊ฒŒ ๋งŽ์•„์„œ ๊ทธ๋ƒฅbootstrap.bundle.min.jsCDN์œผ๋กœ ์ถ”๊ฐ€ โšก ๋ถ€ํŠธ์ŠคํŠธ๋žฉ..
JDK download์ œ์–ดํŒ - ์‹œ์Šคํ…œ - ๊ณ ๊ธ‰์‹œ์Šคํ…œ์„ค์ • - ํ™˜๊ฒฝ๋ณ€์ˆ˜ -C:\Program Files\Java\jdk-17 ์ถ”๊ฐ€Path์— C:\Program Files\Java\jdk-17\bin ์ถ”๊ฐ€ Apache Tomcat downloadzip ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ -> ๊ฒฝ๋กœ๋Š” C๋“œ๋ผ์ด๋ธŒ์— JSP๋ผ๋Š” ํด๋” ๋งŒ๋“ค์–ด์ฃผ๊ณ  ์—ฌ๊ธฐ์— ์••์ถ• ํ’€์–ด์คŒC:\JSP\apache-tomcat-10.1.33\binstartup ๋ฐฐ์น˜ํŒŒ์ผ ์‹คํ–‰ํ•ด์„œ ์„œ๋ฒ„ ์ž‘๋™์‹œํ‚ค๊ธฐ๊ทธ์ „์— ํ˜„์žฌ ์œ„์น˜ ๋ณต์‚ฌํ•ด์„œ cmd(๋ช…๋ นํ”„๋กฌํ”„ํŠธ) ์ฆ‰์‹œ md ๊ด€๋ฆฌ์ž๊ถŒํ•œ์œผ๋กœ ์‹คํ–‰cd C:\JSP\apache-tomcat-10.1.33\binstartup.bat์„œ๋ฒ„ ์‹คํ–‰  ํ”„๋กœ๊ทธ๋žจ์€ ๋„๋ฉด ์•ˆ๋จ๋ฐฐ์น˜ํŒŒ์ผ ์ผœ๋†”์•ผ ์›น์„œ๋ฒ„๊ฐ€ ๊ณ„์†ํ•ด์„œ ์ž‘๋™ http://localhost:8080/์ฃผ์†Œ์ฐฝ..
์„œ๋ธ”๋ฆฟ์˜ ํฌ์›Œ๋“œ ๋ฐฉ๋ฒ• 4๊ฐ€์ง€redirect, Refresh, location, dispatch ์ž์ฃผ ์‚ฌ์šฉ๋˜๋Š” ๊ฒƒsendRedirect์™€ forward(์Šคํ”„๋ง์—์„œ ๋งŽ์ด ์‚ฌ์šฉ) โšกRedirect- HttpServletResponse ๊ฐ์ฒด์˜ sendRedirect()- ์›น๋ธŒ๋ผ์šฐ์ €์— ์žฌ์š”์ฒญ ํ•˜๋Š” ๋ฐฉ์‹- ๋‹ค๋ฅธ ์›น ์ปจํ…Œ์ด๋„ˆ์— ์žˆ๋Š” ์ฃผ์†Œ๋กœ ์ด๋™ ๊ฐ€๋Šฅ- ์ถ”๊ฐ€์ ์œผ๋กœ ๋ฐœ์ƒํ•˜๋Š” ์ฒ˜๋ฆฌ์— ์˜ํ•ด ํฌ์›Œ๋”ฉ๋ณด๋‹ค ์„ฑ๋Šฅ์ด ๋Š๋ฆฌ๋‹ค.sendRedirect("ํฌ์›Œ๋“œํ•  Servlet ๋˜๋Š” JSP") โšกlocation- ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ location ๊ฐ์ฒด์˜ href ์†์„ฑ์„ ์ด์šฉ- ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ์—์„œ ์žฌ์š”์ฒญํ•˜๋Š” ๋ฐฉ์‹location.href = '์š”์ฒญํ•  ์„œ๋ธ”๋ฆฟ ๋˜๋Š” JSP' โšกdispatch- ์ผ๋ฐ˜์ ์œผ๋กœ ํฌ์›Œ๋”ฉ ๊ธฐ๋Šฅ์„ ์ง€์นญ- ์„œ๋ธ”๋ฆฟ์ด ์ง์ ‘ ์š”์ฒญ- Requ..
โœจ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ๊ตฌ์ถ•ํ•˜๊ธฐJDK(Java Development Kit) : ์ž๋ฐ” ๊ฐœ๋ฐœ ๋„๊ตฌํ†ฐ์บฃ(Apache Tomcat) : ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์„œ๋ฒ„(WAS)์ดํด๋ฆฝ์Šค(Eclipse) : ์ฝ”๋”ฉ๊ณผ ์ปดํŒŒ์ผ ํ•จ๊ป˜ ํ•  ์ˆ˜ ์žˆ๋Š” ์ข…ํ•ฉ ๊ฐœ๋ฐœ ํˆด(IDE) 1. ์›น ์„œ๋ฒ„ - ํด๋ผ์ด์–ธํŠธ์˜ ์š”์ฒญ์„ ๋ฐ›์œผ๋ฉด ํ•ด๋‹น ์ฒ˜๋ฆฌ๋ฅผ ํ•ด์„œ ๊ฒฐ๊ณผํŽ˜์ด์ง€๋ฅผ ์‘๋‹ตํ•˜๋„๋ก ๊ตฌ์„ฑ๋œ ์„œ๋ฒ„ 2. WAS- ์›น ์„œ๋ฒ„๋งŒ์œผ๋กœ๋Š” DB์™€ ์—ฐ๋™ํ•˜์—ฌ ์ฒ˜๋ฆฌํ•ด์•ผ ํ•˜๋Š” ๋™์ ์ธ ๋ฐ์ดํ„ฐ ์ฒ˜๋ฆฌ๊ฐ€ ์–ด๋ ต๊ธฐ ๋•Œ๋ฌธ์— DBMS์™€ ์›น์„œ๋ฒ„ ์‚ฌ์ด์—์„œ ์ œ์–ดํ•ด์ฃผ๋Š” ํ”„๋กœ๊ทธ๋žจ 3. JSP- [Dynamic Web Project] => [Web Project] => [New->JSP File] - Java Server Page์˜ ์•ฝ์ž, ์ž๋ฐ”๋กœ ์„œ๋ฒ„ ํŽ˜์ด์ง€ ์ž‘์„ฑํ•˜๊ธฐ ์œ„ํ•œ ์–ธ์–ด- HTML๊ณผ JSP ํƒœ..
1. IntelliJ ์„ค์น˜ 2. ์Šคํ”„๋ง ๋ถ€ํŠธ ์Šคํƒ€ํ„ฐ ์‚ฌ์ดํŠธ๋กœ ์ด๋™ํ•ด์„œ ์Šคํ”„๋ง ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ https://start.spring.io 3. ์š”์ฆ˜ํŠธ๋ Œ๋“œ Gradle > ๊ณผ๊ฑฐ Maven 4. Spring Boot ๋ฒ„์ „ ์ค‘ SNAPSHOT์€ ์•„์ง ๋งŒ๋“ค๊ณ  ์žˆ๋Š” ๋ฒ„์ „ 5. Artifact ๋Š” ํ”„๋กœ์ ํŠธ๋ช…6. Dependencies(์–ด๋–ค ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์“ธ ๊ฒƒ์ธ์ง€?) - Spring Web (์›นํ”„๋กœ์ ํŠธ์šฉ) - Thymeleaf (html ํ…œํ”Œ๋ฆฟ ์—”์ง„) Generate ํ•ด์ฃผ๋ฉด Download ํ•ด์„œ zipํŒŒ์ผ๋กœ ๋ฐ›์Œ ์••์ถ• ํ’€์–ด์„œ IntelliJ์—์„œ ์‹คํ–‰ 7. IntelliJ ์—์„œ Open or Import -> build.gradle ํ”„๋กœ์ ํŠธ ํŒŒ์ผ๋กœ ์—ด๊ธฐ * ์š”์ฆ˜์€ main/test ํด๋”๊ฐ€ ๋‚˜๋‰˜์–ด์ ธ ์žˆ์Œ.(ํ‘œ์ค€ํ™”) - mai..
์ธ์ ˆ๋ฏธ์˜€๋˜๊ฒƒ
'Coding/Spring&JSP' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (2 Page)
์ƒ๋‹จ์œผ๋กœ