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..
๐ฑ Spring
๋ค์๊ณผ ๊ฐ์ ์๋ฌ๊ฐ ๋ฐ์ํ๋ค. 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 =..