CODE NAME
[Spring] 게시판 글 등록 시 한글 깨짐 본문
새로운 게시물을 등록했을 때 한글 입력에 문제가 있다면 우선 브라우저 개발자 도구(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">
'Spring' 카테고리의 다른 글
No mapping found for HTTP request with URI [/favicon.ico] (0) | 2022.05.04 |
---|---|
[Spring] HikariCP 커넥션 풀 Java 8 버전 설정 (0) | 2022.04.11 |
[Spring] @Log4j 오류 (0) | 2022.04.11 |