diff --git a/WebContent/WEB-INF/web.xml b/WebContent/WEB-INF/web.xml index aad14c7..f108b9c 100644 --- a/WebContent/WEB-INF/web.xml +++ b/WebContent/WEB-INF/web.xml @@ -51,6 +51,11 @@ encodingFilter *.file + + + encodingFilter + *.json + - - springapp diff --git a/src/main/java/com/eactive/eai/rms/onl/apim/portalnotice/PortalNoticeManService.java b/src/main/java/com/eactive/eai/rms/onl/apim/portalnotice/PortalNoticeManService.java index 9e125a3..64ffe55 100644 --- a/src/main/java/com/eactive/eai/rms/onl/apim/portalnotice/PortalNoticeManService.java +++ b/src/main/java/com/eactive/eai/rms/onl/apim/portalnotice/PortalNoticeManService.java @@ -5,9 +5,11 @@ import com.eactive.apim.portal.file.entity.FileInfo; import com.eactive.apim.portal.file.service.FileService; import com.eactive.apim.portal.file.service.FileTypeContext; import com.eactive.apim.portal.portalNotice.entity.PortalNotice; +import com.eactive.eai.common.util.ContainerUtil; import com.eactive.eai.rms.common.base.BaseService; import com.eactive.eai.rms.data.entity.onl.apim.portalnotice.PortalNoticeService; import com.eactive.eai.rms.data.entity.onl.apim.portalnotice.PortalNoticeUISearch; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -18,19 +20,28 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.web.multipart.MultipartFile; import java.io.IOException; +import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.Optional; @Service @Transactional(transactionManager = "transactionManagerForEMS") +@Slf4j public class PortalNoticeManService extends BaseService { private final PortalNoticeService portalNoticeService; private final PortalNoticeUIMapper portalNoticeUIMapper; - private final FileService fileService; + private final FileService fileService; private String decodeString(String value) { -// return new String(value.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); + if (ContainerUtil.get() == ContainerUtil.TOMCAT) { + try { + return new String(value.getBytes("euc-kr"), StandardCharsets.UTF_8); + } catch (UnsupportedEncodingException e) { + log.warn("Failed euc-kr to UTF-8", e); + return value; + } + } return new String(value.getBytes(Charset.defaultCharset()), StandardCharsets.UTF_8); } @@ -102,7 +113,7 @@ public class PortalNoticeManService extends BaseService { if (file != null && !file.isEmpty()) { // 새로운 파일이 업로드된 경우에만 처리 String decodedFileName = decodeString(portalNoticeUI.getFileName()); FileTypeContext.setFileType("notice"); - FileInfo fileInfo = fileService.createOrUpdateSingleFile(portalNotice.getFileId(), file, decodedFileName); + FileInfo fileInfo = fileService.createOrUpdateSingleFile(portalNotice.getFileId(), file, decodedFileName, true); if (fileInfo != null) { portalNotice.setFileId(fileInfo.getFileId());