クラス MockPageContext

java.lang.ObjectSE
jakarta.servlet.jsp.JspContext
jakarta.servlet.jsp.PageContext
org.springframework.mock.web.MockPageContext

public class MockPageContext extends jakarta.servlet.jsp.PageContext
PageContext インターフェースのモック実装。カスタム JSP タグをテストするアプリケーションにのみ必要です。

メモ: PageContext.initialize メソッドではなく、コンストラクターによる初期化が必要です。JspWriter への書き込み、リクエストのディスパッチ、handlePageException 呼び出しはサポートしていません。

導入:
1.0.2
作成者:
Juergen Hoeller
  • コンストラクターの詳細

    • MockPageContext

      public MockPageContext()
      デフォルトの MockServletContextMockHttpServletRequestMockHttpServletResponseMockServletConfig で新しい MockPageContext を作成します。
    • MockPageContext

      public MockPageContext(@Nullable jakarta.servlet.ServletContext servletContext)
      デフォルトの MockHttpServletRequestMockHttpServletResponseMockServletConfig で新しい MockPageContext を作成します。
      パラメーター:
      servletContext - JSP ページが実行される ServletContext (実際に ServletContext にアクセスする場合にのみ必要)
    • MockPageContext

      public MockPageContext(@Nullable jakarta.servlet.ServletContext servletContext, @Nullable jakarta.servlet.http.HttpServletRequest request)
      MockHttpServletResponse、MockServletConfig を使用して新しい MockPageContext を作成します。
      パラメーター:
      servletContext - JSP ページが実行される ServletContext
      request - 現在の HttpServletRequest (実際にリクエストにアクセスする場合にのみ必要)
    • MockPageContext

      public MockPageContext(@Nullable jakarta.servlet.ServletContext servletContext, @Nullable jakarta.servlet.http.HttpServletRequest request, @Nullable jakarta.servlet.http.HttpServletResponse response)
      MockServletConfig を使用して新しい MockPageContext を作成します。
      パラメーター:
      servletContext - JSP ページが実行される ServletContext
      request - 現在の HttpServletRequest
      response - 現在の HttpServletResponse (実際にレスポンスに書き込む場合にのみ必要)
    • MockPageContext

      public MockPageContext(@Nullable jakarta.servlet.ServletContext servletContext, @Nullable jakarta.servlet.http.HttpServletRequest request, @Nullable jakarta.servlet.http.HttpServletResponse response, @Nullable jakarta.servlet.ServletConfig servletConfig)
      新しい MockServletConfig を作成します。
      パラメーター:
      servletContext - JSP ページが実行される ServletContext
      request - 現在の HttpServletRequest
      response - 現在の HttpServletResponse
      servletConfig - ServletConfig (タグ内からアクセスされることはほとんどありません)
  • メソッドの詳細

    • initialize

      public void initialize(jakarta.servlet.Servlet servlet, jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, StringSE errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush)
      次で指定:
      クラス jakarta.servlet.jsp.PageContextinitialize 
    • release

      public void release()
      次で指定:
      クラス jakarta.servlet.jsp.PageContextrelease 
    • setAttribute

      public void setAttribute(StringSE name, @Nullable ObjectSE value)
      次で指定:
      クラス jakarta.servlet.jsp.JspContextsetAttribute 
    • setAttribute

      public void setAttribute(StringSE name, @Nullable ObjectSE value, int scope)
      次で指定:
      クラス jakarta.servlet.jsp.JspContextsetAttribute 
    • getAttribute

      public @Nullable ObjectSE getAttribute(StringSE name)
      次で指定:
      クラス jakarta.servlet.jsp.JspContextgetAttribute 
    • getAttribute

      public @Nullable ObjectSE getAttribute(StringSE name, int scope)
      次で指定:
      クラス jakarta.servlet.jsp.JspContextgetAttribute 
    • findAttribute

      public @Nullable ObjectSE findAttribute(StringSE name)
      次で指定:
      クラス jakarta.servlet.jsp.JspContextfindAttribute 
    • removeAttribute

      public void removeAttribute(StringSE name)
      次で指定:
      クラス jakarta.servlet.jsp.JspContextremoveAttribute 
    • removeAttribute

      public void removeAttribute(StringSE name, int scope)
      次で指定:
      クラス jakarta.servlet.jsp.JspContextremoveAttribute 
    • getAttributesScope

      public int getAttributesScope(StringSE name)
      次で指定:
      クラス jakarta.servlet.jsp.JspContextgetAttributesScope 
    • getAttributeNames

      public EnumerationSE<StringSE> getAttributeNames()
    • getAttributeNamesInScope

      public EnumerationSE<StringSE> getAttributeNamesInScope(int scope)
      次で指定:
      クラス jakarta.servlet.jsp.JspContextgetAttributeNamesInScope 
    • getOut

      public jakarta.servlet.jsp.JspWriter getOut()
      次で指定:
      クラス jakarta.servlet.jsp.JspContextgetOut 
    • getELContext

      public @Nullable jakarta.el.ELContext getELContext()
      次で指定:
      クラス jakarta.servlet.jsp.JspContextgetELContext 
    • getSession

      public jakarta.servlet.http.HttpSession getSession()
      次で指定:
      クラス jakarta.servlet.jsp.PageContextgetSession 
    • getPage

      public ObjectSE getPage()
      次で指定:
      クラス jakarta.servlet.jsp.PageContextgetPage 
    • getRequest

      public jakarta.servlet.ServletRequest getRequest()
      次で指定:
      クラス jakarta.servlet.jsp.PageContextgetRequest 
    • getResponse

      public jakarta.servlet.ServletResponse getResponse()
      次で指定:
      クラス jakarta.servlet.jsp.PageContextgetResponse 
    • getException

      public @Nullable ExceptionSE getException()
      次で指定:
      クラス jakarta.servlet.jsp.PageContextgetException 
    • getServletConfig

      public jakarta.servlet.ServletConfig getServletConfig()
      次で指定:
      クラス jakarta.servlet.jsp.PageContextgetServletConfig 
    • getServletContext

      public jakarta.servlet.ServletContext getServletContext()
      次で指定:
      クラス jakarta.servlet.jsp.PageContextgetServletContext 
    • forward

      public void forward(StringSE path) throws jakarta.servlet.ServletException, IOExceptionSE
      次で指定:
      クラス jakarta.servlet.jsp.PageContextforward 
      例外:
      jakarta.servlet.ServletException
      IOExceptionSE
    • include

      public void include(StringSE path) throws jakarta.servlet.ServletException, IOExceptionSE
      次で指定:
      クラス jakarta.servlet.jsp.PageContextinclude 
      例外:
      jakarta.servlet.ServletException
      IOExceptionSE
    • include

      public void include(StringSE path, boolean flush) throws jakarta.servlet.ServletException, IOExceptionSE
      次で指定:
      クラス jakarta.servlet.jsp.PageContextinclude 
      例外:
      jakarta.servlet.ServletException
      IOExceptionSE
    • getContentAsByteArray

      public byte[] getContentAsByteArray()
    • getContentAsString

      public StringSE getContentAsString() throws UnsupportedEncodingExceptionSE
      例外:
      UnsupportedEncodingExceptionSE
    • handlePageException

      public void handlePageException(ExceptionSE ex) throws jakarta.servlet.ServletException, IOExceptionSE
      次で指定:
      クラス jakarta.servlet.jsp.PageContexthandlePageException 
      例外:
      jakarta.servlet.ServletException
      IOExceptionSE
    • handlePageException

      public void handlePageException(ThrowableSE ex) throws jakarta.servlet.ServletException, IOExceptionSE
      次で指定:
      クラス jakarta.servlet.jsp.PageContexthandlePageException 
      例外:
      jakarta.servlet.ServletException
      IOExceptionSE