Package io.github.enxign.shed.toolkit
Class ServletRequestWrapper
java.lang.Object
javax.servlet.ServletRequestWrapper
javax.servlet.http.HttpServletRequestWrapper
io.github.enxign.shed.toolkit.ServletRequestWrapper
- All Implemented Interfaces:
javax.servlet.http.HttpServletRequest
,javax.servlet.ServletRequest
public final class ServletRequestWrapper
extends javax.servlet.http.HttpServletRequestWrapper
POST방식으로 전달된 JSON 데이터 처리 Wrapper Class
- Since:
- 2023-02-01
- Version:
- 1.0
수정일 수정자 수정내용 ---------- --------- ------------------------------- 2020-02-01 first create
- Author:
- enxign
-
Field Summary
FieldsFields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
-
Constructor Summary
ConstructorsConstructorDescriptionServletRequestWrapper
(javax.servlet.http.HttpServletRequest request) HttpServletRequestWrapper 생성자 -
Method Summary
Modifier and TypeMethodDescriptionvoid
appendRequestBody
(String key, Object value) 요청 본문 데이터를 추가하는 메소드static int
copy
(InputStream in, OutputStream out) InputStream을 복사하여 OutputStream으로 전달하는 메소드static byte[]
InputStream을 바이트 배열로 변환하는 메소드javax.servlet.ServletInputStream
요청 본문 데이터를 JSON 형식으로 변환하여 Map으로 반환요청 본문 데이터를 JSON 형식으로 변환하여 Map으로 반환byte[]
요청 본문 데이터를 바이트 배열로 반환Methods inherited from class javax.servlet.http.HttpServletRequestWrapper
authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getHttpServletMapping, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getTrailerFields, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isTrailerFieldsReady, isUserInRole, login, logout, newPushBuilder, upgrade
Methods inherited from class javax.servlet.ServletRequestWrapper
getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, setCharacterEncoding, setRequest, startAsync, startAsync
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface javax.servlet.ServletRequest
getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsync
-
Field Details
-
BUFFER_SIZE
public static final int BUFFER_SIZEBUFFER_SIZE- See Also:
-
-
Constructor Details
-
ServletRequestWrapper
HttpServletRequestWrapper 생성자- Parameters:
request
- HttpServletRequest 객체- Throws:
IOException
- 예외 발생 시
-
-
Method Details
-
copy
InputStream을 복사하여 OutputStream으로 전달하는 메소드- Parameters:
in
- InputStreamout
- OutputStream- Returns:
- 복사된 바이트 수
- Throws:
IOException
- 예외 발생 시
-
copyToByteArray
InputStream을 바이트 배열로 변환하는 메소드- Parameters:
in
- InputStream- Returns:
- 바이트 배열
- Throws:
IOException
- 예외 발생 시
-
getJsonData2Byte
요청 본문 데이터를 바이트 배열로 반환- Returns:
- 요청 본문 데이터
- Throws:
IOException
- 예외 발생 시
-
appendRequestBody
요청 본문 데이터를 추가하는 메소드- Parameters:
key
- 요청 본문 데이터의 키value
- 요청 본문 데이터의 값
-
getJson2Map
public Map<String,Object> getJson2Map() throws com.fasterxml.jackson.core.JsonParseException, com.fasterxml.jackson.databind.JsonMappingException, IOException요청 본문 데이터를 JSON 형식으로 변환하여 Map으로 반환- Returns:
- JSON 형식의 요청 본문 데이터
- Throws:
com.fasterxml.jackson.core.JsonParseException
- JSON 파싱 예외 발생 시com.fasterxml.jackson.databind.JsonMappingException
- JSON 매핑 예외 발생 시IOException
- IO 예외 발생 시
-
getInputStream
요청 본문 데이터를 JSON 형식으로 변환하여 Map으로 반환- Specified by:
getInputStream
in interfacejavax.servlet.ServletRequest
- Overrides:
getInputStream
in classjavax.servlet.ServletRequestWrapper
- Returns:
- JSON 형식의 요청 본문 데이터
- Throws:
IOException
- IO 예외 발생 시
-