tomcat ISO-8859-1 encoding error


java.io.CharConversionException: Not an ISO 8859-1 character: 



변경 전 

response.setContentType("text/html; charset=UTF-8");

response.setCharacterEncoding("UTF-8");

ServletOutputStream out = response.getOutputStream();

out.println(...MY-UTF-8 CODE...);


변경 후

response.setContentType("text/html; charset=UTF-8");

response.setCharacterEncoding("UTF-8");

PrintWrite out = response.getWriter();

out.println(...MY-UTF-8 CODE...);


오류는 

response.setContentType("text/html; charset=UTF-8");

response.setCharacterEncoding("UTF-8");

PrintWriter out = response.getWriter();//

out.println(output);


변경하여 해결됨


톰켓에서 오류나는 이유는 ISO-8859-1 형식으로 되어있어서

get방식 오류

server.xml

<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"  URLEncoding="UTF-8"/>

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URLEncoding="UTF-8"/>

으로 변경


post방식 오류

web.xml

<filter>

<filter-name>setCharacterEncodingFilter</filter-name>

<filter-class>org.apache.catalina.filters.SetCharacterEncodingFilter</filter-class>

<init-param>

    <param-name>encoding</param-name>

    <param-value>UTF-8</param-value>

</init-param>

</filter>

<filter-mapping>

<filter-name>setCharacterEncodingFilter</filter-name>

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

</filter-mapping>


실행시 추가.

VM 아큐면트 추가.

-Dfile.encoding=UTF-8



파일 상단에 추가

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

<%

request.setCharacterEncoding("utf-8"); 

%>



getOutputStream getWriter 차이


https://kdh2625.tistory.com/678



 



+ Recent posts