๐ŸŒฑ Spring

Gson์„ ์ด์šฉํ•ด์„œ HashMap ๋ฐ์ดํ„ฐ๋ฅผ Jsonํ˜•ํƒœ๋กœ ๋ฐ”๊พธ๋ ค๊ณ  ํ•  ๋•Œ ๋ฐœ์ƒํ•œ ์—๋Ÿฌ ํ•ด๋‹น ์—๋Ÿฌ๋Š” ๋ฌธ์ž์—ด์„ Jsonํ˜•ํƒœ๋กœ ๋ฐ”๊พธ๊ณ ์ž ํ•  ๋•Œ ํ•ด๋‹น ๋ฌธ์ž์—ด์— ๊ณต๋ฐฑ์ด๋‚˜ ํŠน์ˆ˜๋ฌธ์ž๊ฐ€ ํฌํ•จ๋˜์–ด์žˆ์„ ๊ฒฝ์šฐ ๋ฐœ์ƒํ•œ๋‹ค. // ํ•ด๋‹น ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜๋Š” ๊ตฌ๋ฌธ Gson gson = new Gson(); HashMap jsonObject = gson.fromJson(input.toString(), new TypeToken(){}.getType()); [ํ•ด๊ฒฐ๋ฐฉ๋ฒ•] ๋ฌธ์ž์—ด์— ๊ณต๋ฐฑ, ํŠน์ˆ˜๋ฌธ์ž๋ฅผ ์ œ๊ฑฐํ•œ๋‹ค. public String replaceStr(String str) { // ๋ฐ์ดํ„ฐ์ค‘ ํŠน์ˆ˜๋ฌธ์ž ๋ฐ ๊ณต๋ฐฑ์œผ๋กœ ์ธํ•ด com.google.gson.stream.MalformedJsonException ๋ฐœ์ƒ String tempStr = str.r..
๋‹ค์Œ๊ณผ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ–ˆ๋‹ค. org.apache.el.parser.ParseException: Encountered " "}" "} "" at line 1, column 3. Was expecting one of: ... ... ... "true" ... "false" ... "null" ... "(" ... "!" ... "not" ... "empty" ... "-" ... ... Expression Language๋ฅผ ์ž˜๋ชป ์‚ฌ์šฉํ–ˆ์„ ๋•Œ ๋ฐœ์ƒํ•˜๋Š” ์—๋Ÿฌ์˜€๋‹ค.
์‚ฌ์šฉ ํˆด : IntelliJ ์‚ฌ์šฉ Framework : Spring MVC ํ”„๋กœ์ ํŠธ์—์„œ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋‹ค๊ฐ€ ๋กœ์ปฌ ๊ฒฝ๋กœ๋ช…์ด ์ž ๊น ๋ฐ”๋€์ ์ด ์žˆ๋‹ค. ๊ทธ ๋’ค๋ถ€ํ„ฐ ์ž๊พธ web.servlet.view.InternalResourceViewResolver ์ชฝ์ด cannot reslove class ํ•˜๋ฉด์„œ ๋‚˜๋ฅผ ์•ฝ์˜ฌ๋ฆฌ๊ธฐ ์‹œ์ž‘ํ–ˆ๋‹ค. ํ”„๋กœ์ ํŠธ ์„ธํŒ…์—์„œ ๋ชจ๋“ˆ๋„ ํ™•์ธํ•ด๋ณด๊ณ  ๊ฒฝ๋กœ๋„ ๋ณ€๊ฒฝํ•ด๋ณด๊ณ ... ์ด๋Ÿฐ ์ €๋Ÿฐ ์‚ฝ์งˆ ๋์— pom.xml์˜ dependency์— spring-webmvc๊ฐ€ ์—†๋Š”๋ฐ ์ด๊ฑธ ์–ด๋–ป๊ฒŒ ์‚ฌ์šฉํ•˜๋ ค๊ณ  ํ•˜๊ณ ์žˆ๋‚˜.. ๋ผ๋Š” ์ƒ๊ฐ์ด ๋“ค์—ˆ๋‹ค. ๊ธฐ์กด์—๋Š” ์–ด๋–ค ๊ฒฝ์œ ์—์„œ spring-webmvc๊ฐ€ ์ž๋™์œผ๋กœ ์ถ”๊ฐ€๋˜์–ด์žˆ์—ˆ๋Š”์ง€๋Š” ์ž˜ ๋ชจ๋ฅด๊ฒ ์œผ๋‚˜ (์•„๋งˆ IntelliJ๊ฐ€ ์–ด๋”˜๊ฐ€์—์„œ ์ž๋™์œผ๋กœ import ํ•ด์คฌ๊ฒ ์ง€) ๋ณด๋‹ค ์ •ํ™•ํ•˜๊ฒŒ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ..
mybatis ํ™˜๊ฒฝ์„ค์ •์„ ํ•˜๋ฉด์„œ ์ผ์–ด๋‚œ ์—๋Ÿฌ๋“ค์„ ์ฐจ๊ทผ์ฐจ๊ทผ ํ•ด๊ฒฐํ•ด๋ณด๋ฉด์„œ ์ ์€ ์ผ์ง€๋‹ค. ๋””๋ ‰ํ† ๋ฆฌ, ํŒจํ‚ค์ง€, ํŒŒ์ผ๋“ค์€ ๋‹ค์Œ๊ณผ๊ฐ™์ด ๊ตฌ์„ฑ๋˜์–ด์žˆ์œผ๋ฉฐ ํ•ด๋‹น ์—๋Ÿฌ์— ๋Œ€ํ•œ ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•์„ ๋ฉ”๋ชจํ•ด๋‘๊ณ ์žํ•œ๋‹ค. ์ฒซ๋ฒˆ์งธ ์—๋Ÿฌ java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: Root WebApplicationContext: startup date [Thu Mar 12 16:14:31 KST 2020]; root of context hierarchy ์‹œ๋„ 1 mybatis-spring์˜ ๋ฒ„์ „์ด ๋งž์ง€ ์•Š์•˜๋‹ค. https://mvnreposi..
Spring์„ ์ด์šฉํ•ด ์ˆœ์ฐจํƒ์ƒ‰๊ณผ ์ด์ง„ํƒ์ƒ‰์˜ ์†๋„์ฐจ์ด๋ฅผ ์žฌ๋ณด์•˜๋‹ค. Controller์™€ Service๋ฅผ ๋ถ„๋ฆฌํ•˜๊ณ  AOP๋„ ์ ์šฉํ•ด๋ณด์•˜๋‹ค. SearchController.java package kr.org.exam.search.controller; import kr.org.exam.search.service.Search; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotati..
Java๋กœ ๊ฐ„๋‹จํ•œ ํด๋ž˜์Šค ํ•˜๋‚˜๋ฅผ ๋งŒ๋“ค ๋•Œ Getter, Setter ๋“ฑ์˜ ํ•จ์ˆ˜๋“ค์„ ์ƒ์„ฑํ•ด์•ผํ•˜๋Š” ๊ท€์ฐฎ์Œ์ด ์žˆ๋‹ค. public class SampleClass{ private T a; public T getterA () { return a; } public void setterA(T a) { this.a = a; } } Lombok์€ Java์—์„œ ์ œ๊ณตํ•˜๋Š” ์–ด๋…ธํ…Œ์ด์…˜ ๊ธฐ๋ฐ˜ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋กœ @Getter, @Setter ๋“ฑ์ด ์žˆ๋‹ค. ๋ฉค๋ฒ„๋ณ€์ˆ˜์— ๊ฐ’์„ ์„ค์ •ํ•˜๋Š” ์ƒ์„ฑ์ž ๋“ฑ์„ ์ž๋™์œผ๋กœ ์ƒ์„ฑํ•ด์ฃผ๊ธฐ๋„ ํ•œ๋‹ค. public class Studnet { private String name; private int grade; private int age; public StudentVO(String name) { this.name =..
_์ฃผ๋…ธ
'๐ŸŒฑ Spring' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (2 Page)