本文整理汇总了Java中play.mvc.Router.routeOnlyStatic方法的典型用法代码示例。如果您正苦于以下问题:Java Router.routeOnlyStatic方法的具体用法?Java Router.routeOnlyStatic怎么用?Java Router.routeOnlyStatic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类play.mvc.Router
的用法示例。
在下文中一共展示了Router.routeOnlyStatic方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseRequest
import play.mvc.Router; //导入方法依赖的package包/类
public static Request parseRequest(HttpServletRequest httpServletRequest) throws Exception {
URI uri = new URI(httpServletRequest.getRequestURI());
String method = httpServletRequest.getMethod().intern();
String path = uri.getPath();
String querystring = httpServletRequest.getQueryString() == null ? "" : httpServletRequest.getQueryString();
if (Logger.isTraceEnabled()) {
Logger.trace("httpServletRequest.getContextPath(): " + httpServletRequest.getContextPath());
Logger.trace("request.path: " + path + ", request.querystring: " + querystring);
}
String contentType = null;
if (httpServletRequest.getHeader("Content-Type") != null) {
contentType = httpServletRequest.getHeader("Content-Type").split(";")[0].trim().toLowerCase().intern();
} else {
contentType = "text/html".intern();
}
if (httpServletRequest.getHeader("X-HTTP-Method-Override") != null) {
method = httpServletRequest.getHeader("X-HTTP-Method-Override").intern();
}
InputStream body = httpServletRequest.getInputStream();
boolean secure = httpServletRequest.isSecure();
String url = uri.toString() + (httpServletRequest.getQueryString() == null ? "" : "?" + httpServletRequest.getQueryString());
String host = httpServletRequest.getHeader("host");
int port = 0;
String domain = null;
if (host.contains(":")) {
port = Integer.parseInt(host.split(":")[1]);
domain = host.split(":")[0];
} else {
port = 80;
domain = host;
}
String remoteAddress = httpServletRequest.getRemoteAddr();
boolean isLoopback = host.matches("^127\\.0\\.0\\.1:?[0-9]*$");
final Request request = Request.createRequest(
remoteAddress,
method,
path,
querystring,
contentType,
body,
url,
host,
isLoopback,
port,
domain,
secure,
getHeaders(httpServletRequest),
getCookies(httpServletRequest));
Request.current.set(request);
Router.routeOnlyStatic(request);
return request;
}