org.apache.struts2.dispatcher.Dispatcher.serviceAction()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(154)

本文整理了Java中org.apache.struts2.dispatcher.Dispatcher.serviceAction()方法的一些代码示例,展示了Dispatcher.serviceAction()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dispatcher.serviceAction()方法的具体详情如下:
包路径:org.apache.struts2.dispatcher.Dispatcher
类名称:Dispatcher
方法名:serviceAction

Dispatcher.serviceAction介绍

暂无

代码示例

代码示例来源:origin: com.atlassian/webwork-compat

dispatcher.serviceAction(request, response, mapping);

代码示例来源:origin: com.googlecode.struts2-conversation/struts2-junit4-plugin

/**
 * Executes an action and returns it's output (not the result returned from
 * execute()), but the actual output that would be written to the response.
 * For this to work the configured result for the action needs to be
 * FreeMarker, or Velocity (JSPs can be used with the Embedded JSP plugin)
 */
protected String executeAction(String uri) throws ServletException, UnsupportedEncodingException {
  request.setRequestURI(uri);
  ActionMapping mapping = getActionMapping(request);
  assertNotNull(mapping);
  Dispatcher.getInstance().serviceAction(request, response, servletContext, mapping);
  if (response.getStatus() != HttpServletResponse.SC_OK)
    throw new ServletException("Error code [" + response.getStatus() + "], Error: [" + response.getErrorMessage() + "]");
  return response.getContentAsString();
}

代码示例来源:origin: org.apache.struts/struts2-junit-plugin

/**
 * Executes an action and returns it's output (not the result returned from
 * execute()), but the actual output that would be written to the response.
 * For this to work the configured result for the action needs to be
 * FreeMarker, or Velocity (JSPs can be used with the Embedded JSP plugin)
 */
protected String executeAction(String uri) throws ServletException, UnsupportedEncodingException {
  request.setRequestURI(uri);
  ActionMapping mapping = getActionMapping(request);
  assertNotNull(mapping);
  Dispatcher.getInstance().serviceAction(request, response, mapping);
  if (response.getStatus() != HttpServletResponse.SC_OK) {
    throw new ServletException("Error code [" + response.getStatus() + "], Error: [" + response.getErrorMessage() + "]");
  }
  return response.getContentAsString();
}

代码示例来源:origin: org.apache.struts/struts2-junit-plugin

/**
 * Executes an action and returns it's output (not the result returned from
 * execute()), but the actual output that would be written to the response.
 * For this to work the configured result for the action needs to be
 * FreeMarker, or Velocity (JSPs can be used with the Embedded JSP plugin)
 */
protected String executeAction(String uri) throws ServletException, UnsupportedEncodingException {
  request.setRequestURI(uri);
  ActionMapping mapping = getActionMapping(request);
  assertNotNull(mapping);
  Dispatcher.getInstance().serviceAction(request, response, mapping);
  if (response.getStatus() != HttpServletResponse.SC_OK)
    throw new ServletException("Error code [" + response.getStatus() + "], Error: ["
        + response.getErrorMessage() + "]");
  return response.getContentAsString();
}

代码示例来源:origin: org.apache.struts/struts2-junit-plugin

/**
 * Executes an action and returns it's output (not the result returned from
 * execute()), but the actual output that would be written to the response.
 * For this to work the configured result for the action needs to be JSON,
 * FreeMarker, or Velocity (JSPs can be used with the Embedded JSP plugin)
 *
 * @param httpMethod HTTP method of request like GET, POST, PUT or DELETE
 * @param uri action uri to test
 * @return execution result
 *
 * @throws ServletException in case of servlet errors
 * @throws UnsupportedEncodingException in case of unsupported encoding
 */
protected String executeAction(String httpMethod, String uri) throws ServletException, UnsupportedEncodingException {
  request.setRequestURI(uri);
  request.setMethod(httpMethod);
  ActionMapping mapping = getActionMapping(request);
  assertNotNull(mapping);
  Dispatcher.getInstance().serviceAction(request, response, mapping);
  if (response.getStatus() != HttpServletResponse.SC_OK)
    throw new ServletException("Error code [" + response.getStatus() + "], Error: ["
        + response.getErrorMessage() + "]");
  return response.getContentAsString();
}

相关文章