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

[JAVA] com.fasterxml.jackson.databind.JsonMappingException: Invalid UTF-8 start byte 0xbf

by ynzu๐Ÿค 2022. 3. 8.
๋ฐ˜์‘ํ˜•

 

์„œ๋ฒ„๋กœ ํ•œ๊ธ€์ด ํฌํ•จ๋œ json ๋ฉ”์‹œ์ง€๋ฅผ ๋ณด๋ƒˆ๋Š”๋ฐ ์•„๋ž˜์™€ ๊ฐ™์€ ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•˜์˜€๋‹ค.

com.fasterxml.jackson.databind.JsonMappingException: Invalid UTF-8 start byte 0xbf

 

ํ•œ๊ธ€์„ ์ž…๋ ฅํ•˜๋Š” html์˜ contentType ๋ฐ pageEncoding์ด UTF-8๋กœ ์„ ์–ธ๋˜์–ด์žˆ์Œ์—๋„ ๋ถˆ๊ตฌํ•˜๊ณ , ์„œ๋ฒ„์ชฝ์—์„œ UTF-8๋กœ ๋ฐ›์ง€ ๋ชปํ•˜์˜€๋‹ค. ๊ทธ๋ฆฌ๊ณ  json string์„ ๋ฐ”์ด๋„ˆ๋ฆฌ๋กœ ๋ณ€ํ™˜ํ•  ๋•Œ UTF-8๋กœ ์ธ์ฝ”๋”ฉ๋˜๋„๋ก ํ•˜์˜€์ง€๋งŒ ํ˜„์ƒ์€ ๋™์ผํ–ˆ๋‹ค.

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

 

ํ•ด๊ฒฐ๋ฐฉ๋ฒ• 1

Run>Run Configurations์—์„œ Tomcat ์„ ํƒ ํ›„ Common ํƒญ์—์„œ Encoding์„ UTF-8๋กœ ๋ฐ”๊ฟ”์ค€๋‹ค.

 

ํ•ด๊ฒฐ๋ฐฉ๋ฒ• 2

  • Run>Run Configurations์—์„œ Tomcat ์„ ํƒ ํ›„ Arguments ํƒญ์˜ VM arguments์— -Dfile.encoding=UTF-8 ์ถ”๊ฐ€
  • apache-tomcat/bin/catalina.sh์— ์•„๋ž˜ ๋‚ด์šฉ ์ถ”๊ฐ€
JAVA_OPTS="-Dfile.encoding=UTF-8

 

 

728x90
๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€