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

    Fields
    Modifier and Type
    Field
    Description
    static final int
    BUFFER_SIZE

    Fields inherited from interface javax.servlet.http.HttpServletRequest

    BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
  • Constructor Summary

    Constructors
    Constructor
    Description
    ServletRequestWrapper(javax.servlet.http.HttpServletRequest request)
    HttpServletRequestWrapper 생성자
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    요청 본문 데이터를 추가하는 메소드
    static int
    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

  • Constructor Details

    • ServletRequestWrapper

      public ServletRequestWrapper(javax.servlet.http.HttpServletRequest request) throws IOException
      HttpServletRequestWrapper 생성자
      Parameters:
      request - HttpServletRequest 객체
      Throws:
      IOException - 예외 발생 시
  • Method Details

    • copy

      public static int copy(InputStream in, OutputStream out) throws IOException
      InputStream을 복사하여 OutputStream으로 전달하는 메소드
      Parameters:
      in - InputStream
      out - OutputStream
      Returns:
      복사된 바이트 수
      Throws:
      IOException - 예외 발생 시
    • copyToByteArray

      public static byte[] copyToByteArray(InputStream in) throws IOException
      InputStream을 바이트 배열로 변환하는 메소드
      Parameters:
      in - InputStream
      Returns:
      바이트 배열
      Throws:
      IOException - 예외 발생 시
    • getJsonData2Byte

      public byte[] getJsonData2Byte() throws IOException
      요청 본문 데이터를 바이트 배열로 반환
      Returns:
      요청 본문 데이터
      Throws:
      IOException - 예외 발생 시
    • appendRequestBody

      public void appendRequestBody(String key, Object value)
      요청 본문 데이터를 추가하는 메소드
      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

      public javax.servlet.ServletInputStream getInputStream() throws IOException
      요청 본문 데이터를 JSON 형식으로 변환하여 Map으로 반환
      Specified by:
      getInputStream in interface javax.servlet.ServletRequest
      Overrides:
      getInputStream in class javax.servlet.ServletRequestWrapper
      Returns:
      JSON 형식의 요청 본문 데이터
      Throws:
      IOException - IO 예외 발생 시