์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
- dfs
- Spring
- ๋์ ํฉ
- ์๋ฎฌ๋ ์ด์
- dynamic debugging
- ๋ฌธ์์ด
- ์์ ์ ๋ ฌ
- ์ด๋ถ ํ์
- CVE
- Reversing
- ์คํ
- ๋ฐ์ดํฌ์คํธ๋ผ
- BFS
- ๋ฐฑํธ๋ํน
- error
- ์ต๋จ ๊ฒฝ๋ก
- OS
- JPA
- java
- ๊ตฌํ
- ๋ถํ ์ ๋ณต
- ๊ทธ๋ฆฌ๋
- GCP
- ๋งต
- DP
- ์ฐ์ ์์ ํ
- thymeleaf
- web
- c++
- ์ฌ๊ท
- Today
- Total
๋ชฉ๋ก๐๐ปโ๏ธ ๊ธฐ๋ณธํ๋ จ/Spring (14)
hades

๐จ ์๋ฌํ์๊ฐ์ ์ ํ์ ๋, ๋น์ฐํ ํ๋์ ๊ณ์ ์ด ์์ฑ๋๋ ๊ฒ์ ๊ธฐ๋ํ๋ค. ํ์ง๋ง, ์ฐ์ฐ์น ์๊ฒ ๋ง์ฐ์ค ์ค๋์์ผ๋ก ์ฐ์ํด์ ํด๋ฆญํ๋๋ฐ, ๋ฐ์ดํฐ๋ฒ ์ด์ค์ 2๊ฐ ์ด์์ ๊ฐ์ ๊ณ์ ์ด ์ ์ฅ๋๋ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ค. ๐ ๋ถ์ ์์ ๊ฐ์ด ๋์์ ์์ฒญ์ด ๋ณด๋ด์ง๋ ๊ฒฝ์ฐ, ์ฆ, ์ฌ๋ฌ ์ฌ์ฉ์๊ฐ ์ฌ์ฉํ๋ ํ๋ก๊ทธ๋จ์์ ๋์์ ์์ฒญ์ ๋ณด๋ธ๋ค๋ฉด, ์ค๋ณตํ์ธ๊ณผ ๋ณ๊ฐ๋ก ์ด์ ๊ฐ์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ ์ ์์์ ๊นจ๋ฌ์๋ค. ๐ ํด๊ฒฐ ํ์๊ฐ์ ์์๋ ์ฃผ๋ก ์ฌ์ฉ์ ์ด๋ฆ์ผ๋ก ์ค๋ณต์ฌ๋ถ๋ฅผ ๊ฒฐ์ ํ๋ฏ๋ก, ์ฌ์ฉ์ ์ด๋ฆ์ unique ์ ์ฝ์กฐ๊ฑด์ ์ถ๊ฐํ๋ค. ๊ทธ ํ, ์คํ ๋ง์ฐ์ค๋ฅผ ์ด์ฉํ์ฌ ์งง์ ์๊ฐ์ ๊ฐ์ ์์ฒญ์ ์ฌ๋ฌ ๊ฐ ๋ณด๋ด์ ๋ฐ์ํ๋ ์ค๋ฅ๋ฅผ ํ์ธํ๋ ๋ค์๊ณผ ๊ฐ์๋ค.DataIntegrityViolationException์ด ๋ฐ์ํ๋ ๊ฒ์ ํ์ธํ ์ ์๊ณ , ์ด..

๐จ ์๋ฌํ์ฌ, ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ ์์ ๊ฐ์ด ์ ์ฅ๋ ์ํ์ด๋ค. ๊ธ ์์ฑ์ ํ๋ฉด, ๋ฐ์ดํฐ๋ฒ ์ด์ค์ FOOD ํ ์ด๋ธ์ ๋ณํจ์์ด POST ํ ์ด๋ธ์๋ง ์ถ๊ฐ๋๋ ๊ฒ์ ๊ธฐ๋ํ๋ค. ํ์ง๋ง, ์ค๋์ ์๋ฆฌ ์๋์ ๊ฒ์๊ธ์ด ์๋ฌด ๊ฒ๋ ๋ํ๋์ง ์๋๋ค. ๋ฐ์ดํฐ๋ฒ ์ด์ค๋ฅผ ๋ณด๋ ์ด์ฝ๋ฆฟ+์ผ์ดํฌ๊ฐ ์ถ๊ฐ๋์๋ค. ๐ ๋ถ์๋ฌธ์ ๋ ๊ธ์ ์์ฑํ๊ณ , redirectํ ๋, UrlEncoder๋ฅผ ์ฌ์ฉํ์ฌ ๊ฒฝ๋ก๋ฅผ ์์ฑํ๊ธฐ ๋๋ฌธ์ด๋ค.return "redirect:/food/foodInfo/" + URLEncoder.encode(food.getName(), "UTF-8"); ๐ ํด๊ฒฐ@GetMapping("/foodInfo/{foodName}")public String foodInfo(@PathVariable(name = "foodName") Strin..

๐จ ์๋ฌ๋งจ ์์ input์ธ ํ์ฌ ๋น๋ฐ๋ฒํธ๋ฅผ ์ฌ๋ฐ๋ฅด์ง ์๊ฒ ์ ๋ ฅํ๊ณ , ๋ณ๊ฒฝ ์ Controller์์ BindingResult์ ์๋ฌ๋ฅผ ๋ํด์ ์๋ฌ ๋ฉ์ธ์ง๋ฅผ ๋ํ๋ด๊ณ ์ถ์๋ค. ํ์ง๋ง, ๋ณ๊ฒฝ ์์๋ ์๋ฌด๋ฐ ์๋ฌ ๋ฉ์ธ์ง๊ฐ ๋ํ๋์ง ์๋๋ค. ์ ์ด๋ฐ ๊ฒ์ผ๊น? ๐ ๋ถ์@PostMapping("/mypage/change")public String changePassword(@Validated @ModelAttribute(name = "passwordDto") PasswordDto passwordDto, BindingResult bindingResult, HttpServletRequest request, Model model){ HttpSession session = request.getSession();..

๐จ ์๋ฌ์นํจ3 ๊ฒ์๊ธ์ ์ง์ฐ๊ณ ์ถ์ด์ ์ญ์ ๋ฅผ ๋๋ฅด๋ฉด, ์๋์ ๊ฐ์ด ์นํจ1์ด ์ง์์ก๋ค. action์ ๊ฒฝ๋ก๋ ์ ๋๋ก ๋ ๊ฒ์ ํ์ธํ๋๋ฐ, ์ ์ด๋ฐ ์ผ์ด ์ผ์ด๋๋ ๊ฒ์ผ๊น? ๐ ๋ถ์ ์์ ์ญ์ ๋ฌธ์ ๋ ๊ฒ์๊ธ์ ๋์ดํ ๋, th:each๋ฅผ ์ฌ์ฉํ์๊ณ , ์์ ๊ณผ ์ญ์ ๋ฒํผ์ ๋ฐฐ์นํ๋ ๊ณผ์ ์์ form์ id๋ฅผ ์ฌ์ฉํ๋๋ฐ, ์ด id๊ฐ ๊ฒ์๊ธ๋ง๋ค ๋ชจ๋ ๊ฐ๊ฒ ๋์ด ๋งจ ์์ ์๋ ๊ฒ์๊ธ์ด ์ง์์ง ๊ฒ์ด์๋ค. ๐ ํด๊ฒฐ ์์ ..
๐จ ์๋ฌNo static resource food/foodinfo/%EB%8B%AD%EA%B0%88%EB%B9%84. ๐ ๋ถ์๋ ์ด ๋ ์์ด ๋ฑ์ฅํ๋ค. ๋ง์ง๋ง ๋ถ๋ถ์ ๋ฉ๋ด ์ด๋ฆ์ ๊ทธ๋๋ก ์ ๋ฌํ๋๋ฐ, ์ ๋ฌ ๋ฌธ์ ์ธ๊ฐ ์ถ์ด์ Url Encoding ์ฒ๋ฆฌ๋ ํด์ฃผ์๋๋ฐ ์ฌ์ ํ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ค. ๋ฌธ์ ๋ ๊ฒฝ๋ก ์์์ ๋์๋ฌธ์๋ฅผ ๊ตฌ๋ถ์ด ์ด๋ฃจ์ด์ ธ์ผ ํ๋ค๋ ๊ฒ์ด์๋ค. ์ปจํธ๋กค๋ฌ์์๋ /food/foodInfo/๋ก ์ค์ ํ๋๋ฐ, /food/foodinfo๋ก ์ ๋ฌํ๊ธฐ ๋๋ฌธ์ ์ค๋ฅ๊ฐ ๋ฐ์ํ๋ค. ๐ ํด๊ฒฐ๋์๋ฌธ์์ ์ ์ํ์ฌ ์ฌ๋ฐ๋ฅด๊ฒ ๋ฐ๊ฟ์ค๋ค.

๋ณธ ๊ธ์ ํ๋ก์ ํธ๋ฅผ ์งํํ๋ฉด์, AI์ ์ง๋ฌธ์ ํ๊ณ ์๋ต์ ๋ฐ์์ผ ํ๋ ์๋น์ค๋ฅผ ๊ตฌํํ๊ธฐ ์ํด AI api๋ฅผ ํ์ตํ๋ฉด์ ์์ฑํ๋ ๊ธ์ด๋ค. Spring์์๋ AI๋ฅผ ๋งค์ฐ ์ฝ๊ฒ ์ง์ํด์ฃผ๋ dependency๊ฐ ์๋ค. ์ ํ๋ธ์ ๋งํฌ๋ ํ์ํ๊ธฐ ๋๋ฌธ์ ๊ฐ์ ๊ตฌ๊ธ ์๋น์ค์ธ Gemini AI๋ฅผ ์ฌ์ฉํ๊ธฐ๋ก ํ๋ค. ์ฒ์, build.gradle์์ Edit Starters๋ก ์๋์ ๊ฐ์ด Gemini AI๋ฅผ ์ถ๊ฐํ๊ณ ํ๋ค.ํ์ง๋ง, dependency๊ฐ ์ธ์๋์ง ์๊ณ , ๋นจ๊ฐ์ค ์ฒ์ง๊ฐ ๋์๋ค. ์บ์ ์ญ์ , ์ฌ๋น๋ ๋ฑ ์ฌ๋ฌ๊ฐ์ง ๋ฐฉ๋ฒ์ ์๋ํด๋ณด์์ง๋ง ํด๊ฒฐํ ์ ์์๋ค. (๊น์ ๋นก์นจ) ํน์๋ ํด์ Spring Initilizr๋ฅผ ์ด์ฉํ์ฌ Gemini๋ฅผ ์ถ๊ฐํ ์๋ก์ด ํ๋ก์ ํธ๋ฅผ ๋ง๋ค๊ณ , build.gradle์ ํ์ธํด๋ณด์๋ค. ์๋กญ..

ํ๋ก์ ํธ๋ฅผ ์งํํ๋ ๋์ค, ํ์ผ ์ ๋ก๋ ๊ธฐ๋ฅ์ด ํ์ํ์ฌ ํ์ต ํ, ํ๋ก์ ํธ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ์ ๋ฆฌํ ๊ธ์ด๋ค. ๋ณธ์ธ์ ๊ฒ์๊ธ์ ์ด๋ฏธ์ง ํ์ผ์ ์ฌ๋ฆฌ๋ ๊ฒ์ ๋ชฉํ๋ก ํ์๊ณ , ๊ทธ๋ก ์ธํด ๊ฒ์๊ธ๊ณผ ํ์ผ ๊ฐ์ ์ฐ๊ด๊ด๊ณ๊ฐ ์๋ค. Multipart๋ฌธ์, ์ซ์ ๋ฐ์ดํฐ๋ ๊ธฐ๋ณธ์ ์ผ๋ก application/x-www-form-urlencoded ๋ฐฉ์์ ์ด์ฉํ๋ค. ํ์ง๋ง, ํ์ผ์ ์ด๋ค๊ณผ ๋ค๋ฅด๊ฒ ๋ฐ์ด๋๋ฆฌ ๋ฐ์ดํฐ๋ก ๋ณด๋ด์ผ ํ๋ค. ๋ฌธ์, ์ซ์, ํ์ผ์ ๋์์ ๋ณด๋ด์ผ ํ๋ ๊ฒฝ์ฐ์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๋ค. ์ด๋ฅผ ํด๊ฒฐํ๋ ๊ฒ์ด Form ํ๊ทธ์ enctype="multipart/form-data" ๋ฅผ ์ถ๊ฐํ๋ ๊ฒ์ด๋ค. Content-Disposition์ ์ํด ๊ตฌ๋ถ๋๊ณ , ํ์ผ์ ์ถ๊ฐ์ ์ผ๋ก filename๊ณผ Content-Type์ด ์ถ๊ฐ๋๊ณ ๋ฐ์ด๋๋ฆฌ ๋ฐ..
๐จ ์๋ฌModel has no value for key foodId ๐ ๋ถ์@PostMapping("post/delete/{id}")public String deletePost(@PathVariable(name = "id") Long id, RedirectAttributes redirectAttributes){ Post post = postService.findPost(id); Long foodId = post.getFood().getId(); postService.remove(id); return "redirect:/food/foodInfo/{foodId}"}id๋ก post๋ฅผ ์ฐพ๊ณ , post์ ์ฐ๊ฒฐ๋ foodId๋ฅผ ์ฐพ์ redirect ๊ฒฝ๋ก ์์ ๋ฃ์ด์ฃผ์๋ค. @GetMappin..
๐จ ์๋ฌCaused by: org.thymeleaf.exceptions.TemplateProcessingException: Could not parse as expression: "/posts/${post.id}" (template: "loginHome" - line 15, col 12) ๐ ๋ถ์post.id๋ฅผ ์ด์ฉํ์ฌ ๋์ ์ผ๋ก ๊ฒฝ๋ก๋ฅผ ์ง์ ํ๋ ค๊ณ ํ๋๋ฐ, /posts/${post.id}๋ฅผ ํ์ฑํ ์ ์๋ค๊ณ ํ๋ค. ๐ ํด๊ฒฐ์๋ ๋ ํผ๋ฐ์ค ๋ธ๋ก๊ทธ๋ฅผ ์ฐธ๊ณ ํ๋, ${}๋ก ๊ฐ์ธ์ง ๋ณ์๋ง์ด ์๋๋ผ ๋ค๋ฅธ ๋ฌธ์์ด์ด ์๋ ๊ฒฝ์ฐ์๋ ๋ํ๊ธฐ๋ก ์๊ฑฐ๋, | |๋ก ๊ฐ์ธ์ฃผ์ด์ผ ํ๋ค. ๐ ๋ ํผ๋ฐ์คhttps://velog.io/@susu1991/Thymeleaf#%EB%A6%AC%ED%84%B0%EB%9F%B4 Thymelea..
๐จ ์๋ฌ Caused by: org.attoparser.ParseException: Error resolving template [fragments/header], template might not exist or might not be accessible by any of the configured Template Resolvers (template: "home" - line 3, col 7) Caused by: org.thymeleaf.exceptions.TemplateInputException: Error resolving template [fragments/header], template might not exist or might not be accessible by any of the co..