Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Tags
more
Archives
Today
Total
관리 메뉴

CODE NAME

[Spring] 게시판 글 등록 시 한글 깨짐 본문

Spring

[Spring] 게시판 글 등록 시 한글 깨짐

센우 2022. 4. 12. 13:08

새로운 게시물을 등록했을 때 한글 입력에 문제가 있다면 우선 브라우저 개발자 도구(F12)에서 'Network' 탭을 열어둔 상태에서 테이터를 보내 한글이 깨져서 전송되는지 확인하고 문제가 없다면 스프링 MVC 쪽에서 한글을 처리하는 필터를 등록해야 된다.

 

 

< web.xml > 추가

<filter>
	<filter-name>encoding</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>encoding</filter-name>
	<servlet-name>appServlet</servlet-name>
</filter-mapping>

 

오류

cvc-id.3: A field of identity constraint 'web-app-servlet-name-uniqueness' matched element 'web-app', but this element does not have a simple type.

< web.xml > 수정

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://JAVA.sun.com/xml/ns/javaee https://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">