类 MockPageContext

java.lang.Object
jakarta.servlet.jsp.JspContext
jakarta.servlet.jsp.PageContext
cn.taketoday.mock.web.MockPageContext

public class MockPageContext extends jakarta.servlet.jsp.PageContext
Mock implementation of the PageContext interface. Only necessary for testing applications when testing custom JSP tags.

Note: Expects initialization via the constructor rather than via the PageContext.initialize method. Does not support writing to a JspWriter, request dispatching, or handlePageException calls.

从以下版本开始:
4.0
作者:
Juergen Hoeller
  • 字段详细资料

    • servletContext

      private final jakarta.servlet.ServletContext servletContext
    • request

      private final jakarta.servlet.http.HttpServletRequest request
    • response

      private final jakarta.servlet.http.HttpServletResponse response
    • servletConfig

      private final jakarta.servlet.ServletConfig servletConfig
    • attributes

      private final Map<String,Object> attributes
    • out

      @Nullable private jakarta.servlet.jsp.JspWriter out
  • 构造器详细资料

    • MockPageContext

      public MockPageContext()
    • MockPageContext

      public MockPageContext(@Nullable jakarta.servlet.ServletContext servletContext)
      Create new MockPageContext with a default MockHttpServletRequest, MockHttpServletResponse, MockServletConfig.
      参数:
      servletContext - the ServletContext that the JSP page runs in (only necessary when actually accessing the ServletContext)
    • MockPageContext

      public MockPageContext(@Nullable jakarta.servlet.ServletContext servletContext, @Nullable jakarta.servlet.http.HttpServletRequest request)
      Create new MockPageContext with a MockHttpServletResponse, MockServletConfig.
      参数:
      servletContext - the ServletContext that the JSP page runs in
      request - the current HttpServletRequest (only necessary when actually accessing the request)
    • MockPageContext

      public MockPageContext(@Nullable jakarta.servlet.ServletContext servletContext, @Nullable jakarta.servlet.http.HttpServletRequest request, @Nullable jakarta.servlet.http.HttpServletResponse response)
      Create new MockPageContext with a MockServletConfig.
      参数:
      servletContext - the ServletContext that the JSP page runs in
      request - the current HttpServletRequest
      response - the current HttpServletResponse (only necessary when actually writing to the response)
    • 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)
      Create new MockServletConfig.
      参数:
      servletContext - the ServletContext that the JSP page runs in
      request - the current HttpServletRequest
      response - the current HttpServletResponse
      servletConfig - the ServletConfig (hardly ever accessed from within a tag)
  • 方法详细资料

    • initialize

      public void initialize(jakarta.servlet.Servlet servlet, jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush)
      指定者:
      initialize 在类中 jakarta.servlet.jsp.PageContext
    • release

      public void release()
      指定者:
      release 在类中 jakarta.servlet.jsp.PageContext
    • setAttribute

      public void setAttribute(String name, @Nullable Object value)
      指定者:
      setAttribute 在类中 jakarta.servlet.jsp.JspContext
    • setAttribute

      public void setAttribute(String name, @Nullable Object value, int scope)
      指定者:
      setAttribute 在类中 jakarta.servlet.jsp.JspContext
    • getAttribute

      @Nullable public Object getAttribute(String name)
      指定者:
      getAttribute 在类中 jakarta.servlet.jsp.JspContext
    • getAttribute

      @Nullable public Object getAttribute(String name, int scope)
      指定者:
      getAttribute 在类中 jakarta.servlet.jsp.JspContext
    • findAttribute

      @Nullable public Object findAttribute(String name)
      指定者:
      findAttribute 在类中 jakarta.servlet.jsp.JspContext
    • removeAttribute

      public void removeAttribute(String name)
      指定者:
      removeAttribute 在类中 jakarta.servlet.jsp.JspContext
    • removeAttribute

      public void removeAttribute(String name, int scope)
      指定者:
      removeAttribute 在类中 jakarta.servlet.jsp.JspContext
    • getAttributesScope

      public int getAttributesScope(String name)
      指定者:
      getAttributesScope 在类中 jakarta.servlet.jsp.JspContext
    • getAttributeNames

      public Enumeration<String> getAttributeNames()
    • getAttributeNamesInScope

      public Enumeration<String> getAttributeNamesInScope(int scope)
      指定者:
      getAttributeNamesInScope 在类中 jakarta.servlet.jsp.JspContext
    • getOut

      public jakarta.servlet.jsp.JspWriter getOut()
      指定者:
      getOut 在类中 jakarta.servlet.jsp.JspContext
    • getExpressionEvaluator

      @Deprecated @Nullable public jakarta.servlet.jsp.el.ExpressionEvaluator getExpressionEvaluator()
      已过时。
      指定者:
      getExpressionEvaluator 在类中 jakarta.servlet.jsp.JspContext
    • getELContext

      @Nullable public jakarta.el.ELContext getELContext()
      指定者:
      getELContext 在类中 jakarta.servlet.jsp.JspContext
    • getVariableResolver

      @Deprecated @Nullable public jakarta.servlet.jsp.el.VariableResolver getVariableResolver()
      已过时。
      指定者:
      getVariableResolver 在类中 jakarta.servlet.jsp.JspContext
    • getSession

      public jakarta.servlet.http.HttpSession getSession()
      指定者:
      getSession 在类中 jakarta.servlet.jsp.PageContext
    • getPage

      public Object getPage()
      指定者:
      getPage 在类中 jakarta.servlet.jsp.PageContext
    • getRequest

      public jakarta.servlet.ServletRequest getRequest()
      指定者:
      getRequest 在类中 jakarta.servlet.jsp.PageContext
    • getResponse

      public jakarta.servlet.ServletResponse getResponse()
      指定者:
      getResponse 在类中 jakarta.servlet.jsp.PageContext
    • getException

      @Nullable public Exception getException()
      指定者:
      getException 在类中 jakarta.servlet.jsp.PageContext
    • getServletConfig

      public jakarta.servlet.ServletConfig getServletConfig()
      指定者:
      getServletConfig 在类中 jakarta.servlet.jsp.PageContext
    • getServletContext

      public jakarta.servlet.ServletContext getServletContext()
      指定者:
      getServletContext 在类中 jakarta.servlet.jsp.PageContext
    • forward

      public void forward(String path) throws jakarta.servlet.ServletException, IOException
      指定者:
      forward 在类中 jakarta.servlet.jsp.PageContext
      抛出:
      jakarta.servlet.ServletException
      IOException
    • include

      public void include(String path) throws jakarta.servlet.ServletException, IOException
      指定者:
      include 在类中 jakarta.servlet.jsp.PageContext
      抛出:
      jakarta.servlet.ServletException
      IOException
    • include

      public void include(String path, boolean flush) throws jakarta.servlet.ServletException, IOException
      指定者:
      include 在类中 jakarta.servlet.jsp.PageContext
      抛出:
      jakarta.servlet.ServletException
      IOException
    • getContentAsByteArray

      public byte[] getContentAsByteArray()
    • getContentAsString

      public String getContentAsString() throws UnsupportedEncodingException
      抛出:
      UnsupportedEncodingException
    • handlePageException

      public void handlePageException(Exception ex) throws jakarta.servlet.ServletException, IOException
      指定者:
      handlePageException 在类中 jakarta.servlet.jsp.PageContext
      抛出:
      jakarta.servlet.ServletException
      IOException
    • handlePageException

      public void handlePageException(Throwable ex) throws jakarta.servlet.ServletException, IOException
      指定者:
      handlePageException 在类中 jakarta.servlet.jsp.PageContext
      抛出:
      jakarta.servlet.ServletException
      IOException