반응형

jsp에서 Servlet으로 요청보낼때 한글이 깨지는 경우.

 

jsp

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

servlet

@Override
	public  void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		resp.setContentType("text/html;charset=UTF-8");
		String test1= req.getParameter("test1");
		String test2 = req.getParameter("test2");
		PrintWriter out = resp.getWriter();
		out.println(test1);
		out.println(test2);

	}

tomcat

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

 

 

톰캣 설정파일의 경로는 보통 아래와 같습니다. 

워크스페이스 경로\Servers\Tomcat v9.0 Server at localhost-config\server.xml

반응형

+ Recent posts