반응형

JAVA로 

HttpServletRequest를 받을 때 charset을 설정하는 방법

request.setCharaterEncoding("charset이름");

@RequestMapping(method = RequestMethod.POST,path = "/result")
public String result(HttpServletRequest request, HttpServletResponse response,Model model) {
        try {
            request.setCharacterEncoding("EUC-KR"); 
            HashMap<String, String> map = new HashMap<>();
            map.put("P_STATUS", request.getParameter("P_STATUS"));
            map.put("P_RMESG1", request.getParameter("P_RMESG1"));
        }catch(Exception e){
            e.printStackTrace();
        }
        return "form";
}
반응형

+ Recent posts