한글 인코딩 오류 수정

This commit is contained in:
daekuk1
2026-02-03 16:45:28 +09:00
parent 6558d21bb0
commit 2fdf8bedd4
@@ -455,19 +455,19 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
logger.info("========================================"); logger.info("========================================");
// ===== 인코딩 확인 로그 끝 ===== // ===== 인코딩 확인 로그 끝 =====
param.put("recvData", new String(arg)); param.put("recvData", new String(arg, "EUC-KR"));
} catch(Exception e) { } catch(Exception e) {
logger.error("MessageSync.err - don't read the XML File - " + new String(arg), e); logger.error("MessageSync.err - don't read the XML File - " + new String(arg, "EUC-KR"), e);
param.put("recvData", ""); param.put("recvData", "");
} }
// byte[]로부터 XML 파싱 (BOM 제거) // byte[]로부터 XML 파싱 (BOM 제거) - EUC-KR로 읽기
String xmlContent = new String(arg).trim(); String xmlContent = new String(arg, "EUC-KR").trim();
// BOM 제거 (UTF-8 BOM: EF BB BF) // BOM 제거 (UTF-8 BOM: EF BB BF)
if (xmlContent.startsWith("\uFEFF")) { if (xmlContent.startsWith("\uFEFF")) {
xmlContent = xmlContent.substring(1); xmlContent = xmlContent.substring(1);
} }
Document doc = builder.build(new ByteArrayInputStream(xmlContent.getBytes())); Document doc = builder.build(new ByteArrayInputStream(xmlContent.getBytes("EUC-KR")));
param.put("logPrcssSeqno", UUIDGenerator.getUUID()); param.put("logPrcssSeqno", UUIDGenerator.getUUID());
// xml 1.1 // xml 1.1
@@ -624,10 +624,11 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
ServletOutputStream sos = null; ServletOutputStream sos = null;
try { try {
response.setContentType("application/xml; charset=EUC-KR");
sos = response.getOutputStream(); sos = response.getOutputStream();
sos.write(resultS.getBytes()); sos.write(resultS.getBytes("EUC-KR"));
} catch( Exception e ) { } catch( Exception e ) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
if( sis != null ) sis.close(); if( sis != null ) sis.close();
if( sos != null ) sos.close(); if( sos != null ) sos.close();
@@ -661,16 +662,16 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
// 초기화 // 초기화
DataSourceContextHolder.setDataSourceType(DataSourceTypeManager.getDataSourceType(schema)); DataSourceContextHolder.setDataSourceType(DataSourceTypeManager.getDataSourceType(schema));
try { try {
// // 요청 전문 // // 요청 전문
sis = request.getInputStream(); sis = request.getInputStream();
JSONObject json = (JSONObject) JSONValue.parse(new InputStreamReader(sis)); JSONObject json = (JSONObject) JSONValue.parse(new InputStreamReader(sis, "EUC-KR"));
// JJB 향후제거 shkim 2020-05-13 연계 테스트 체크 // JJB 향후제거 shkim 2020-05-13 연계 테스트 체크
logger.error("\n\n MMI SYNC Request : " + json.toString()); logger.error("\n\n MMI SYNC Request : " + json.toString());
// log 기록 // log 기록
byte[] arg = new byte[request.getContentLength()]; byte[] arg = new byte[request.getContentLength()];
int resultSet =0; int resultSet =0;
int total = 0; int total = 0;
@@ -680,10 +681,10 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
total += resultSet; total += resultSet;
resultSet = sis.readLine(arg, total, 1024); resultSet = sis.readLine(arg, total, 1024);
} }
param.put("recvData", new String(arg)); param.put("recvData", new String(arg, "EUC-KR"));
} catch(Exception e) { } catch(Exception e) {
logger.error("MessageSync.err - don't read the JSON File - " + new String(arg), e); logger.error("MessageSync.err - don't read the JSON File - " + new String(arg, "EUC-KR"), e);
param.put("recvData", ""); param.put("recvData", "");
} }
@@ -724,10 +725,11 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
ServletOutputStream sos = null; ServletOutputStream sos = null;
try { try {
response.setContentType("application/json; charset=EUC-KR");
sos = response.getOutputStream(); sos = response.getOutputStream();
sos.write(resultS.toString().getBytes()); sos.write(resultS.toString().getBytes("EUC-KR"));
} catch( Exception e ) { } catch( Exception e ) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
if( sis != null ) sis.close(); if( sis != null ) sis.close();
if( sos != null ) sos.close(); if( sos != null ) sos.close();