๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

spring43

Spring - DB์ ‘๊ทผ4 (JdbcTemplete) ์ˆœ์ˆ˜ Jdbc์™€ ๋™์ผํ•œ ํ™˜๊ฒฝ์„ค์ •์„ ํ•˜๋ฉด ๋œ๋‹ค. ์Šคํ”„๋ง JdbcTemplate๊ณผ MyBatis ๊ฐ™์€ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋Š” JDBC API์—์„œ ๋ณธ ๋ฐ˜๋ณต ์ฝ”๋“œ๋ฅผ ๋Œ€๋ถ€๋ถ„ ์ œ๊ฑฐํ•ด์ค€๋‹ค. ํ•˜์ง€๋งŒ SQL์€ ์ง์ ‘ ์ž‘์„ฑํ•ด์•ผ ํ•œ๋‹ค. package hello.hellospring.repository; import hello.hellospring.domain.Member; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; import org.springframework.jdbc.core.. 2023. 7. 4.
Spring - DB์ ‘๊ทผ2 (๊ณ ์ „ jdbc ์ด์šฉ) ๊ณ ์ „ jdbc๋ฅผ ์ด์šฉํ•ด์„œ ์ €์žฅ์†Œ๋ฅผ ์ƒ์„ฑ package hello.hellospring.repository; import hello.hellospring.domain.Member; import org.springframework.jdbc.datasource.DataSourceUtils; import javax.sql.DataSource; import java.sql.*; import java.util.ArrayList; import java.util.List; import java.util.Optional; public class JdbcMemberRepository implements MemberRepository { private final DataSource dataSource; public Jdbc.. 2023. 7. 4.
Spring - ์›น MVC ์˜ˆ์ œ (ํšŒ์› ์กฐํšŒ) Model addAttribute(String name, Object value) - value ๊ฐ์ฒด๋ฅผ name ์ด๋ฆ„์œผ๋กœ ์ถ”๊ฐ€ํ•œ๋‹ค. ๋ทฐ ์ฝ”๋“œ์—์„œ๋Š” name์œผ๋กœ ์ง€์ •ํ•œ ์ด๋ฆ„์„ ํ†ตํ•ด์„œ value๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. Model addAttribute(Object value) - value๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค. value์˜ ํŒจํ‚ค์ง€ ์ด๋ฆ„์„ ์ œ์™ธํ•œ ๋‹จ์ˆœ ํด๋ž˜์Šค ์ด๋ฆ„์„ ๋ชจ๋ธ ์ด๋ฆ„์œผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค. ์ด ๋•Œ ์ฒซ ๊ธ€์ž๋Š” ์†Œ๋ฌธ์ž๋กœ ์ฒ˜๋ฆฌํ•œ๋‹ค. - value๊ฐ€ ๋ฐฐ์—ด์ด๊ฑฐ๋‚˜ ์ปฌ๋ ‰์…˜์ธ ๊ฒฝ์šฐ ์ฒซ ๋ฒˆ์งธ ์›์†Œ์˜ ํด๋ž˜์Šค ์ด๋ฆ„ ๋’ค์— "List"๋ฅผ ๋ถ™์ธ ๊ฑธ ๋ชจ๋ธ ์ด๋ฆ„์œผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค. ์ด ๊ฒฝ์šฐ์—๋„ ํด๋ž˜์Šค ์ด๋ฆ„์˜ ์ฒซ์ž๋Š” ์†Œ๋ฌธ์ž๋กœ ์ฒ˜๋ฆฌํ•œ๋‹ค. ์ถœ์ฒ˜: https://devlogofchris.tistory.com/53 ํšŒ์›์กฐํšŒ ์ปจํŠธ๋กค๋Ÿฌ @GetMapping("/members.. 2023. 7. 4.
Spring - ์›น MVC ์˜ˆ์ œ (ํšŒ์› ๋“ฑ๋ก) ํšŒ์› ๋“ฑ๋ก ํผ ์ปจํŠธ๋กค๋Ÿฌ ์ƒ์„ฑ @Controller public class MemberController { // private final MemberService memberService = new MemberService(); private final MemberService memberService; //์ปจํŠธ๋กค๋Ÿฌ์™€ ์„œ๋น„์Šค๋ฅผ ์—ฐ๊ฒฐ @Autowired public MemberController(MemberService memberService) { this.memberService = memberService; } @GetMapping("/members/new") public String createForm() { return "members/createMemberForm"; } @PostMapping(.. 2023. 7. 4.