类 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 thePageContext
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, orhandlePageException
calls.- 从以下版本开始:
- 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(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(ServletContext servletContext, 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(ServletContext servletContext, HttpServletRequest request, 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(ServletContext servletContext, HttpServletRequest request, HttpServletResponse response, 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, Object value)
- 指定者:
setAttribute
在类中JspContext
setAttribute
public void setAttribute(String name, Object value, int scope)
- 指定者:
setAttribute
在类中JspContext
getAttribute
public Object getAttribute(String name)
- 指定者:
getAttribute
在类中JspContext
getAttribute
public Object getAttribute(String name, int scope)
- 指定者:
getAttribute
在类中JspContext
findAttribute
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
public ELContext getELContext()
- 指定者:
getELContext
在类中JspContext
getVariableResolver
@Deprecated 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
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
- 抛出:
ServletException
IOException
include
public void include(String path) throws ServletException, IOException
- 指定者:
include
在类中PageContext
- 抛出:
ServletException
IOException
include
public void include(String path, boolean flush) throws ServletException, IOException
- 指定者:
include
在类中PageContext
- 抛出:
ServletException
IOException
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