org.apache.catalina.connector.Response.setCharacterEncoding()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(264)

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

Response.setCharacterEncoding介绍

[英]Overrides the name of the character encoding used in the body of the request. This method must be called prior to reading request parameters or reading input using getReader().
[中]重写请求正文中使用的字符编码的名称。必须在读取请求参数或使用getReader()读取输入之前调用此方法。

代码示例

代码示例来源:origin: org.glassfish.main.web/web-core

@Override
public void setCharacterEncoding(String arg0) {
  // Disallow operation if the object has gone out of scope
  if (response == null) {
    throw new IllegalStateException(rb.getString(LogFacade.NULL_RESPONSE_OBJECT));
  }
  response.setCharacterEncoding(arg0);
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

@Override
public void setCharacterEncoding(String arg0) {
  if (response == null) {
    throw new IllegalStateException(
            sm.getString("responseFacade.nullResponse"));
  }
  response.setCharacterEncoding(arg0);
}

代码示例来源:origin: org.jboss.web/jbossweb

public void setCharacterEncoding(String arg0) {
  if (response == null) {
    throw MESSAGES.nullResponseFacade();
  }
  response.setCharacterEncoding(arg0);
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

@Override
public void setCharacterEncoding(String arg0) {
  if (response == null) {
    throw new IllegalStateException(
            sm.getString("responseFacade.nullResponse"));
  }
  response.setCharacterEncoding(arg0);
}

代码示例来源:origin: codefollower/Tomcat-Research

@Override
public void setCharacterEncoding(String arg0) {
  if (response == null) {
    throw new IllegalStateException(
            sm.getString("responseFacade.nullResponse"));
  }
  response.setCharacterEncoding(arg0);
}

代码示例来源:origin: tomcat/catalina

public void setCharacterEncoding(String arg0) {
  if (response == null) {
    throw new IllegalStateException(
            sm.getString("responseFacade.nullResponse"));
  }
  response.setCharacterEncoding(arg0);
}

代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina

@Override
public void setCharacterEncoding(String arg0) {
  if (response == null) {
    throw new IllegalStateException(
            sm.getString("responseFacade.nullResponse"));
  }
  response.setCharacterEncoding(arg0);
}

代码示例来源:origin: org.apache.catalina/com.springsource.org.apache.catalina

@Override
public void setCharacterEncoding(String arg0) {
  if (response == null) {
    throw new IllegalStateException(
            sm.getString("responseFacade.nullResponse"));
  }
  response.setCharacterEncoding(arg0);
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7

@Override
public void setCharacterEncoding(String arg0) {
  if (response == null) {
    throw new IllegalStateException(
            sm.getString("responseFacade.nullResponse"));
  }
  response.setCharacterEncoding(arg0);
}

代码示例来源:origin: jboss.web/jbossweb

public void setCharacterEncoding(String arg0) {
  if (response == null) {
    throw new IllegalStateException(
            sm.getString("responseFacade.nullResponse"));
  }
  response.setCharacterEncoding(arg0);
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

@Override
public void setCharacterEncoding(String arg0) {
  if (response == null) {
    throw new IllegalStateException(
            sm.getString("responseFacade.nullResponse"));
  }
  response.setCharacterEncoding(arg0);
}

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

@Override
public void setCharacterEncoding(String arg0) {
  if (response == null) {
    throw new IllegalStateException(
            sm.getString("responseFacade.nullResponse"));
  }
  response.setCharacterEncoding(arg0);
}

代码示例来源:origin: org.wso2.carbon.apimgt/org.wso2.carbon.apimgt.interceptor

/**
 * Send an Error Response in application/xml content type
 * 
 * @param response
 * @param payload
 */
public static void handleRestFailure(Response response, String payload) {
  response.setStatus(403);
  response.setContentType("application/xml");
  response.setCharacterEncoding("UTF-8");
  try {
    response.getWriter().write(payload);
  } catch (IOException e) {
    log.error("Error in sending fault response", e);
  }
}

代码示例来源:origin: org.osivia.portal.core/osivia-portal-jbossas-jbossweb-lib

/*      */   public PrintWriter getWriter()
/*      */     throws IOException
/*      */   {
/*  603 */     if (this.usingOutputStream) {
/*  604 */       throw new IllegalStateException(sm.getString("coyoteResponse.getWriter.ise"));
/*      */     }
/*      */ 
/*  607 */     if (Globals.STRICT_SERVLET_COMPLIANCE)
/*      */     {
/*  620 */       setCharacterEncoding(getCharacterEncoding());
/*      */     }
/*      */ 
/*  623 */     this.usingWriter = true;
/*  624 */     this.outputBuffer.checkConverter();
/*  625 */     if (this.writer == null) {
/*  626 */       this.writer = new CoyoteWriter(this.outputBuffer);
/*      */     }
/*  628 */     return this.writer;
/*      */   }
/*      */

代码示例来源:origin: tomcat/catalina

setCharacterEncoding(getCharacterEncoding());

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

setCharacterEncoding(getCharacterEncoding());

代码示例来源:origin: org.nuxeo.lib.runtime/nuxeo-runtime-tomcat-adapter

private void getFile(String path, Request req, Response resp) {
  File file = getSDKFile(path);
  if (file == null) {
    resp.setStatus(404);
  } else {
    resp.setContentType("text/plain");
    resp.setCharacterEncoding("UTF-8");
    resp.setStatus(200);
    try {
      Writer out = resp.getWriter();
      sendFile(file, out);
      out.flush();
    } catch (IOException e) {
      resp.setStatus(500);
      log.error("Failed to send file: " + file, e);
    }
  }
}

代码示例来源:origin: org.apache.tomcat/tomcat-catalina

private boolean sendErrorPage(String location, Response response) {
  File file = new File(location);
  if (!file.isAbsolute()) {
    file = new File(getContainer().getCatalinaBase(), location);
  }
  if (!file.isFile() || !file.canRead()) {
    getContainer().getLogger().warn(
        sm.getString("errorReportValve.errorPageNotFound", location));
    return false;
  }
  // Hard coded for now. Consider making this optional. At Valve level or
  // page level?
  response.setContentType("text/html");
  response.setCharacterEncoding("UTF-8");
  try (OutputStream os = response.getOutputStream();
      InputStream is = new FileInputStream(file);){
    IOTools.flow(is, os);
  } catch (IOException e) {
    getContainer().getLogger().warn(
        sm.getString("errorReportValve.errorPageIOException", location), e);
    return false;
  }
  return true;
}

代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core

private boolean sendErrorPage(String location, Response response) {
  File file = new File(location);
  if (!file.isAbsolute()) {
    file = new File(getContainer().getCatalinaBase(), location);
  }
  if (!file.isFile() || !file.canRead()) {
    getContainer().getLogger().warn(
        sm.getString("errorReportValve.errorPageNotFound", location));
    return false;
  }
  // Hard coded for now. Consider making this optional. At Valve level or
  // page level?
  response.setContentType("text/html");
  response.setCharacterEncoding("UTF-8");
  try (OutputStream os = response.getOutputStream();
      InputStream is = new FileInputStream(file);){
    IOTools.flow(is, os);
  } catch (IOException e) {
    getContainer().getLogger().warn(
        sm.getString("errorReportValve.errorPageIOException", location), e);
    return false;
  }
  return true;
}

代码示例来源:origin: org.wso2.carbon.identity.auth.rest/org.wso2.carbon.identity.context.rewrite.valve

private void handleInvalidTenantDomainErrorResponse(Response response, int error, String tenantDomain) throws
      IOException, ServletException {

    response.setContentType("application/json");
    response.setStatus(error);
    response.setCharacterEncoding("UTF-8");
    JsonObject errorResponse = new JsonObject();
    String errorMsg = "invalid tenant domain : " + tenantDomain;
    errorResponse.add("code", error);
    errorResponse.add("message", errorMsg);
    errorResponse.add("description", errorMsg);
    response.getWriter().print(errorResponse.toString());
  }
}

相关文章

Response类方法