본문 바로가기

Spring

[Spring / eclipse] 한글깨짐 UTF-8 설정

한글깨짐수정하는 방법에 대해서 알아보자.

 

인코딩 UTF-8로 설정하지 않으면 한글이 깨져서 '??'로 찍혀서 나오는걸 볼 수 있다.

한글깨짐

이를 해결하기 위해서 인코딩 변경을 해보자.

 

  • [Window] > [Preferences]  > [General] > [Content Types] > [Text]

 

  •  [General] > [Content Types] > [Text] > [Java Properties File]

 

  • [General] > [Content Types] > [Text] > [Java Properties File] >  [Spring Properties File]

 

  •  [General] > [Editors] > [Text Editors] > [Spelling]

 

  •  [General] > [Workspace]

 

  •  [Web] > [CSS Files]

 

  •  [Web] > [HTML Files]

 

  •  [Web] > [JSP Files]

 

  • [src] > [main] > [webapp] > [WEB-INF] > 'web.xml'

아래 코드를 추가해준다.

<filter> 
    <filter-name>encodingFilter</filter-name>
    <filter-class> 
        org.springframework.web.filter.CharacterEncodingFilter
    </filter-class> 
    <init-param>
        <param-name>encoding</param-name> 
        <param-value>UTF-8</param-value> 
    </init-param> <init-param> 
        <param-name>forceEncoding</param-name> 
        <param-value>true</param-value> 
    </init-param> 
</filter> 
<filter-mapping> 
    <filter-name>encodingFilter</filter-name> 
    <url-pattern>/*</url-pattern> 
</filter-mapping>

 

바꿀건 다 바꾼것 같아서 프로젝트 실행시켰는데, 그래도 한글이 깨진다?

그렇다면 .jsp 파일 자체에서 한번 더 설정을 해주면 해결된다!

 

위 그림과 같이 아래 코드를 jsp파일에 추가해 주었다.

<%@ page session="false" pageEncoding="UTF-8" %>

<meta charset="UTF-8">

 

그러고나서 다시 프로젝트를 실행시키면 아래 그림과 같이 정상적으로 한글이 나오는 것을 볼 수 있다


또 더 할 수 있는 인코딩설정이 있다면 댓글로 알려주세요!

 

즐코~

안뇽~~~ :)