本文整理汇总了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());
}