类 MockPageContext
- java.lang.Object
- javax.servlet.jsp.JspContext
- javax.servlet.jsp.PageContext
- org.springframework.mock.web.MockPageContext
public class MockPageContext extends PageContext
Mock implementation of thePageContextinterface. Only necessary for testing applications when testing custom JSP tags.Note: Expects initialization via the constructor rather than via the
PageContext.initializemethod. Does not support writing to a JspWriter, request dispatching, orhandlePageExceptioncalls.- 从以下版本开始:
- 1.0.2
- 作者:
- Juergen Hoeller
字段概要
从类继承的字段 javax.servlet.jsp.PageContext
APPLICATION, APPLICATION_SCOPE, CONFIG, EXCEPTION, OUT, PAGE, PAGE_SCOPE, PAGECONTEXT, REQUEST, REQUEST_SCOPE, RESPONSE, SESSION, SESSION_SCOPE
构造器概要
构造器 构造器 说明 MockPageContext()Create new MockPageContext with a defaultMockServletContext,MockHttpServletRequest,MockHttpServletResponse,MockServletConfig.MockPageContext(ServletContext servletContext)Create new MockPageContext with a defaultMockHttpServletRequest,MockHttpServletResponse,MockServletConfig.MockPageContext(ServletContext servletContext, HttpServletRequest request)Create new MockPageContext with a MockHttpServletResponse, MockServletConfig.MockPageContext(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response)Create new MockPageContext with a MockServletConfig.MockPageContext(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, ServletConfig servletConfig)Create new MockServletConfig.
方法概要
从类继承的方法 javax.servlet.jsp.PageContext
getErrorData, pushBody
从类继承的方法 javax.servlet.jsp.JspContext
popBody, pushBody
构造器详细资料
MockPageContext
public MockPageContext()
Create new MockPageContext with a defaultMockServletContext,MockHttpServletRequest,MockHttpServletResponse,MockServletConfig.
MockPageContext
public MockPageContext(@Nullable ServletContext servletContext)
Create new MockPageContext with a defaultMockHttpServletRequest,MockHttpServletResponse,MockServletConfig.- 参数:
servletContext- the ServletContext that the JSP page runs in (only necessary when actually accessing the ServletContext)
MockPageContext
public MockPageContext(@Nullable ServletContext servletContext, @Nullable HttpServletRequest request)
Create new MockPageContext with a MockHttpServletResponse, MockServletConfig.- 参数:
servletContext- the ServletContext that the JSP page runs inrequest- the current HttpServletRequest (only necessary when actually accessing the request)
MockPageContext
public MockPageContext(@Nullable ServletContext servletContext, @Nullable HttpServletRequest request, @Nullable HttpServletResponse response)
Create new MockPageContext with a MockServletConfig.- 参数:
servletContext- the ServletContext that the JSP page runs inrequest- the current HttpServletRequestresponse- the current HttpServletResponse (only necessary when actually writing to the response)
MockPageContext
public MockPageContext(@Nullable ServletContext servletContext, @Nullable HttpServletRequest request, @Nullable HttpServletResponse response, @Nullable ServletConfig servletConfig)
Create new MockServletConfig.- 参数:
servletContext- the ServletContext that the JSP page runs inrequest- the current HttpServletRequestresponse- the current HttpServletResponseservletConfig- the ServletConfig (hardly ever accessed from within a tag)
方法详细资料
initialize
public void initialize(Servlet servlet, ServletRequest request, ServletResponse response, String errorPageURL, boolean needsSession, int bufferSize, boolean autoFlush)
- 指定者:
initialize在类中PageContext
release
public void release()
- 指定者:
release在类中PageContext
setAttribute
public void setAttribute(String name, @Nullable Object value)
- 指定者:
setAttribute在类中JspContext
setAttribute
public void setAttribute(String name, @Nullable Object value, int scope)
- 指定者:
setAttribute在类中JspContext
getAttribute
@Nullable public Object getAttribute(String name)
- 指定者:
getAttribute在类中JspContext
getAttribute
@Nullable public Object getAttribute(String name, int scope)
- 指定者:
getAttribute在类中JspContext
findAttribute
@Nullable public Object findAttribute(String name)
- 指定者:
findAttribute在类中JspContext
removeAttribute
public void removeAttribute(String name)
- 指定者:
removeAttribute在类中JspContext
removeAttribute
public void removeAttribute(String name, int scope)
- 指定者:
removeAttribute在类中JspContext
getAttributesScope
public int getAttributesScope(String name)
- 指定者:
getAttributesScope在类中JspContext
getAttributeNames
public Enumeration<String> getAttributeNames()
getAttributeNamesInScope
public Enumeration<String> getAttributeNamesInScope(int scope)
- 指定者:
getAttributeNamesInScope在类中JspContext
getOut
public JspWriter getOut()
- 指定者:
getOut在类中JspContext
getExpressionEvaluator
@Deprecated public ExpressionEvaluator getExpressionEvaluator()
已过时。- 指定者:
getExpressionEvaluator在类中JspContext
getELContext
@Nullable public ELContext getELContext()
- 指定者:
getELContext在类中JspContext
getVariableResolver
@Deprecated @Nullable public VariableResolver getVariableResolver()
已过时。- 指定者:
getVariableResolver在类中JspContext
getSession
public HttpSession getSession()
- 指定者:
getSession在类中PageContext
getPage
public Object getPage()
- 指定者:
getPage在类中PageContext
getRequest
public ServletRequest getRequest()
- 指定者:
getRequest在类中PageContext
getResponse
public ServletResponse getResponse()
- 指定者:
getResponse在类中PageContext
getException
@Nullable public Exception getException()
- 指定者:
getException在类中PageContext
getServletConfig
public ServletConfig getServletConfig()
- 指定者:
getServletConfig在类中PageContext
getServletContext
public ServletContext getServletContext()
- 指定者:
getServletContext在类中PageContext
forward
public void forward(String path) throws ServletException, IOException
- 指定者:
forward在类中PageContext- 抛出:
ServletExceptionIOException
include
public void include(String path) throws ServletException, IOException
- 指定者:
include在类中PageContext- 抛出:
ServletExceptionIOException
include
public void include(String path, boolean flush) throws ServletException, IOException
- 指定者:
include在类中PageContext- 抛出:
ServletExceptionIOException
getContentAsByteArray
public byte[] getContentAsByteArray()
getContentAsString
public String getContentAsString() throws UnsupportedEncodingException
handlePageException
public void handlePageException(Exception ex) throws ServletException, IOException
handlePageException
public void handlePageException(Throwable ex) throws ServletException, IOException