本文整理了Java中org.apache.coyote.Response.setContentType
方法的一些代码示例,展示了Response.setContentType
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Response.setContentType
方法的具体详情如下:
包路径:org.apache.coyote.Response
类名称:Response
方法名:setContentType
[英]Sets the content type. This method must preserve any response charset that may already have been set via a call to response.setContentType(), response.setLocale(), or response.setCharacterEncoding().
[中]设置内容类型。此方法必须保留可能已经通过调用response设置的任何response字符集。setContentType(),响应。setLocale()或响应。setCharacterEncoding()。
代码示例来源:origin: codefollower/Tomcat-Research
/**
* Set internal fields for special header names.
* Called from set/addHeader.
* Return true if the header is special, no need to set the header.
*/
private boolean checkSpecialHeader( String name, String value) {
// XXX Eliminate redundant fields !!!
// ( both header and in special fields )
if( name.equalsIgnoreCase( "Content-Type" ) ) {
setContentType( value );
return true;
}
if( name.equalsIgnoreCase( "Content-Length" ) ) {
try {
long cL=Long.parseLong( value );
setContentLength( cL );
return true;
} catch( NumberFormatException ex ) {
// Do nothing - the spec doesn't have any "throws"
// and the user might know what he's doing
return false;
}
}
return false;
}
代码示例来源:origin: codefollower/Tomcat-Research
coyoteResponse.setContentType(null);
return;
代码示例来源:origin: org.apache.coyote/com.springsource.org.apache.coyote
/**
* Set internal fields for special header names.
* Called from set/addHeader.
* Return true if the header is special, no need to set the header.
*/
private boolean checkSpecialHeader( String name, String value) {
// XXX Eliminate redundant fields !!!
// ( both header and in special fields )
if( name.equalsIgnoreCase( "Content-Type" ) ) {
setContentType( value );
return true;
}
if( name.equalsIgnoreCase( "Content-Length" ) ) {
try {
long cL=Long.parseLong( value );
setContentLength( cL );
return true;
} catch( NumberFormatException ex ) {
// Do nothing - the spec doesn't have any "throws"
// and the user might know what he's doing
return false;
}
}
if( name.equalsIgnoreCase( "Content-Language" ) ) {
// XXX XXX Need to construct Locale or something else
}
return false;
}
代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina
coyoteResponse.setContentType(null);
return;
代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core
/**
* Set internal fields for special header names.
* Called from set/addHeader.
* Return true if the header is special, no need to set the header.
*/
private boolean checkSpecialHeader( String name, String value) {
// XXX Eliminate redundant fields !!!
// ( both header and in special fields )
if( name.equalsIgnoreCase( "Content-Type" ) ) {
setContentType( value );
return true;
}
if( name.equalsIgnoreCase( "Content-Length" ) ) {
try {
long cL=Long.parseLong( value );
setContentLength( cL );
return true;
} catch( NumberFormatException ex ) {
// Do nothing - the spec doesn't have any "throws"
// and the user might know what he's doing
return false;
}
}
return false;
}
代码示例来源:origin: org.ops4j.pax.tipi/org.ops4j.pax.tipi.tomcat-embed-core
getCoyoteResponse().setContentType(null);
return;
代码示例来源:origin: org.jboss.web/jbossweb
/**
* Set internal fields for special header names.
* Called from set/addHeader.
* Return true if the header is special, no need to set the header.
*/
private boolean checkSpecialHeader( String name, String value) {
// XXX Eliminate redundant fields !!!
// ( both header and in special fields )
if( name.equalsIgnoreCase( "Content-Type" ) ) {
setContentType( value );
return true;
}
if( name.equalsIgnoreCase( "Content-Length" ) ) {
try {
long cL=Long.parseLong( value );
setContentLength( cL );
return true;
} catch( NumberFormatException ex ) {
// Do nothing - the spec doesn't have any "throws"
// and the user might know what he's doing
return false;
}
}
if( name.equalsIgnoreCase( "Content-Language" ) ) {
// XXX XXX Need to construct Locale or something else
}
return false;
}
代码示例来源:origin: org.apache.tomcat/tomcat-catalina
getCoyoteResponse().setContentType(null);
return;
代码示例来源:origin: org.apache.geronimo.ext.tomcat/catalina
/**
* Set internal fields for special header names.
* Called from set/addHeader.
* Return true if the header is special, no need to set the header.
*/
private boolean checkSpecialHeader( String name, String value) {
// XXX Eliminate redundant fields !!!
// ( both header and in special fields )
if( name.equalsIgnoreCase( "Content-Type" ) ) {
setContentType( value );
return true;
}
if( name.equalsIgnoreCase( "Content-Length" ) ) {
try {
long cL=Long.parseLong( value );
setContentLength( cL );
return true;
} catch( NumberFormatException ex ) {
// Do nothing - the spec doesn't have any "throws"
// and the user might know what he's doing
return false;
}
}
if( name.equalsIgnoreCase( "Content-Language" ) ) {
// XXX XXX Need to construct Locale or something else
}
return false;
}
代码示例来源:origin: jboss.web/jbossweb
/**
* Set internal fields for special header names.
* Called from set/addHeader.
* Return true if the header is special, no need to set the header.
*/
private boolean checkSpecialHeader( String name, String value) {
// XXX Eliminate redundant fields !!!
// ( both header and in special fields )
if( name.equalsIgnoreCase( "Content-Type" ) ) {
setContentType( value );
return true;
}
if( name.equalsIgnoreCase( "Content-Length" ) ) {
try {
long cL=Long.parseLong( value );
setContentLength( cL );
return true;
} catch( NumberFormatException ex ) {
// Do nothing - the spec doesn't have any "throws"
// and the user might know what he's doing
return false;
}
}
if( name.equalsIgnoreCase( "Content-Language" ) ) {
// XXX XXX Need to construct Locale or something else
}
return false;
}
代码示例来源:origin: org.apache.coyote.springsource/com.springsource.org.apache.coyote.springsource
/**
* Set internal fields for special header names.
* Called from set/addHeader.
* Return true if the header is special, no need to set the header.
*/
private boolean checkSpecialHeader( String name, String value) {
// XXX Eliminate redundant fields !!!
// ( both header and in special fields )
if( name.equalsIgnoreCase( "Content-Type" ) ) {
setContentType( value );
return true;
}
if( name.equalsIgnoreCase( "Content-Length" ) ) {
try {
long cL=Long.parseLong( value );
setContentLength( cL );
return true;
} catch( NumberFormatException ex ) {
// Do nothing - the spec doesn't have any "throws"
// and the user might know what he's doing
return false;
}
}
if( name.equalsIgnoreCase( "Content-Language" ) ) {
// XXX XXX Need to construct Locale or something else
}
return false;
}
代码示例来源:origin: com.ovea.tajin.server/tajin-server-tomcat7
/**
* Set internal fields for special header names.
* Called from set/addHeader.
* Return true if the header is special, no need to set the header.
*/
private boolean checkSpecialHeader( String name, String value) {
// XXX Eliminate redundant fields !!!
// ( both header and in special fields )
if( name.equalsIgnoreCase( "Content-Type" ) ) {
setContentType( value );
return true;
}
if( name.equalsIgnoreCase( "Content-Length" ) ) {
try {
long cL=Long.parseLong( value );
setContentLength( cL );
return true;
} catch( NumberFormatException ex ) {
// Do nothing - the spec doesn't have any "throws"
// and the user might know what he's doing
return false;
}
}
if( name.equalsIgnoreCase( "Content-Language" ) ) {
// XXX XXX Need to construct Locale or something else
}
return false;
}
代码示例来源:origin: org.osivia.portal.core/osivia-portal-jbossas-jbossweb-lib
/* 739 */ this.coyoteResponse.setContentType(type);
代码示例来源:origin: jboss.web/jbossweb
coyoteResponse.setContentType(type);
代码示例来源:origin: tomcat/catalina
coyoteResponse.setContentType(type);
代码示例来源:origin: org.apache.catalina/com.springsource.org.apache.catalina
coyoteResponse.setContentType(type);
代码示例来源:origin: org.jboss.web/jbossweb
coyoteResponse.setContentType(type);
代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9
coyoteResponse.setContentType(type);
代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9
coyoteResponse.setContentType(type);
代码示例来源:origin: jboss.remoting/jboss-remoting
private void versionedWrite(int version, Object responseObject, Request req, org.apache.coyote.Response res, ResponseMap response)
throws IOException
{
switch (version)
{
case Version.VERSION_1:
case Version.VERSION_2:
case Version.VERSION_2_2:
{
String responseContentType = (String) response.get("Content-Type");
if(responseContentType == null)
{
responseContentType = responseObject == null ? req.getContentType() : WebUtil.getContentType(responseObject);
}
res.setContentType(responseContentType);
Marshaller marshaller = getMarshaller();
if (marshaller instanceof VersionedMarshaller)
((VersionedMarshaller) marshaller).write(responseObject, response.getOutputStream(), version);
else
marshaller.write(responseObject, response.getOutputStream());
return;
}
default:
{
throw new IOException("Can not send response due to version (" + version + ") not being supported. Supported versions: " + Version.VERSION_1 + ", " + Version.VERSION_2 + ", " + Version.VERSION_2_2);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!