본문 바로가기

PROGRAMING/SPRING_FRAMEWORK

Spring Framework 에서 UTF-8 한글 설정 && jsp include 페이지 한글깨짐 방지

web.xml 에 아래 구문 추가


</servlet-mapping>

<filter>

<!-- http://blog.naver.com/PostView.nhn?blogId=dlaelel1&logNo=100138643494 -->

<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>

</filter>

<filter-mapping>

<filter-name>encodingFilter</filter-name>

<url-pattern>/*</url-pattern>

</filter-mapping>

</web-app>


HelloWeb-servlet.xml  추가

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">

<property name="prefix" value="/WEB-INF/jsp/" />

<property name="suffix" value=".jsp" />

 <property name="contentType" value="text/html; charset=UTF-8"/>

</bean>



jsp include 를 사용했다면 include 당하는 쪽의 jsp 페이지에 아래 지시문을 적어주어야 한글이 깨지지 않는다.

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