本文整理匯總了Java中com.sun.jersey.spi.container.ContainerRequest.getMediaType方法的典型用法代碼示例。如果您正苦於以下問題:Java ContainerRequest.getMediaType方法的具體用法?Java ContainerRequest.getMediaType怎麽用?Java ContainerRequest.getMediaType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sun.jersey.spi.container.ContainerRequest
的用法示例。
在下文中一共展示了ContainerRequest.getMediaType方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: filter
import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
@Override
public ContainerRequest filter(final ContainerRequest req) {
if (log.isTraceEnabled()) {
String baseUri = req.getBaseUri().getPath();
String method = req.getMethod();
String path = req.getPath();
MediaType mediaType = req.getMediaType();
String dbg = Strings.of("\r\nRESTEndPoint: {}" +
"\r\n---------------------------------------------------------------------" +
"\r\n Method: {}" +
"\r\n Path: {}" +
"\r\nContent-Type: {}" +
"\r\n---------------------------------------------------------------------")
.customizeWith(baseUri,
method,
path,
mediaType != null ? mediaType
: "not specified")
.asString();
log.trace(dbg);
}
return req;
}
示例2: filter
import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
@Override
public ContainerRequest filter(final ContainerRequest request) {
if (logger.isInfoEnabled()) {
String requestInfo = request.getPath() + " (" + request.getMethod() +
(request.getMediaType() == null ? "" : " " + request.getMediaType()) + ")";
logger.info(requestInfo);
StringBuilder parameters = new StringBuilder("Params: ");
Set<Entry<String, List<String>>> entrySet = request.getFormParameters().entrySet();
for (Entry<String, List<String>> parameter : entrySet) {
parameters.append(parameter.getKey()).append(":").append(parameter.getValue()).append(", ");
}
if (!entrySet.isEmpty()) {
parameters.setLength(parameters.length() - ", ".length());
logger.info(parameters.toString());
}
}
return request;
}
示例3: filter
import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
@Override
public ContainerRequest filter(final ContainerRequest request) {
if (logger.isInfoEnabled()) {
String requestInfo = request.getPath() + " (" + request.getMethod() +
(request.getMediaType() == null ? "" : " " + request.getMediaType()) + ")";
logger.debug(requestInfo);
StringBuilder parameters = new StringBuilder("Params: ");
Set<Entry<String, List<String>>> entrySet = request.getFormParameters().entrySet();
for (Entry<String, List<String>> parameter : entrySet) {
parameters.append(parameter.getKey()).append(":").append(parameter.getValue()).append(", ");
}
if (!entrySet.isEmpty()) {
parameters.setLength(parameters.length() - ", ".length());
logger.debug(parameters.toString());
}
}
return request;
}
示例4: filter
import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
@Override
public ContainerRequest filter(ContainerRequest request) {
if (request.getMediaType() != null &&
request.getMediaType()
.isCompatible(MediaType.APPLICATION_JSON_TYPE)) {
adjustContentType(request);
validate(request);
}
return request;
}
示例5: adjustContentType
import com.sun.jersey.spi.container.ContainerRequest; //導入方法依賴的package包/類
protected void adjustContentType(ContainerRequest request) {
MediaType newMt = new MediaType("application", "json", ImmutableMap
.<String, String>builder()
.putAll(request.getMediaType().getParameters())
.put(MediaTypes.SCHEMA_ATTRIBUTE, schema).build());
// container request caches the header......
request.getRequestHeaders().remove(HttpHeaders.CONTENT_TYPE);
request.getMediaType();
request.getRequestHeaders()
.putSingle(HttpHeaders.CONTENT_TYPE, newMt.toString());
}