当前位置: 首页>>代码示例>>Java>>正文


Java HttpServletRequest.getPathTranslated方法代码示例

本文整理汇总了Java中javax.servlet.http.HttpServletRequest.getPathTranslated方法的典型用法代码示例。如果您正苦于以下问题:Java HttpServletRequest.getPathTranslated方法的具体用法?Java HttpServletRequest.getPathTranslated怎么用?Java HttpServletRequest.getPathTranslated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.servlet.http.HttpServletRequest的用法示例。


在下文中一共展示了HttpServletRequest.getPathTranslated方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doFilter

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
@Override
public void doFilter(ServletRequest request, ServletResponse response,
        FilterChain chain) throws IOException, ServletException {

    if (!(request instanceof HttpServletRequest) || !(response instanceof HttpServletResponse)) {
        throw new ServletException("Just supports HTTP requests");
    }
    HttpServletRequest httpRequest = (HttpServletRequest) request;
    HttpServletResponse httpResponse = (HttpServletResponse) response;

    int cacheTime = 0;

    for(Pattern pattern : TIME_FOR_URL.keySet()) {
        if(pattern.matcher(httpRequest.getRequestURI()).matches()) {
            cacheTime = TIME_FOR_URL.get(pattern);
        }
    }
    httpResponse.setHeader(HttpHeaders.CACHE_CONTROL, "max-age="+cacheTime+", must-revalidate");

    httpRequest.getRequestURI();

    String key = httpRequest.getPathTranslated();
    if(cache.containsKey(key)) {
        String expectedEtag = httpRequest.getHeader(HttpHeaders.IF_NONE_MATCH);
        String currentEtag = cache.get(key);
        if(expectedEtag != null && expectedEtag.equals(currentEtag)) {
            httpResponse.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
            return;
        }
    }

    filter.doFilter(request, response, chain);
    String etag = httpResponse.getHeader(HttpHeaders.ETAG);
    cache.put(key, etag);
}
 
开发者ID:BBVA,项目名称:mirrorgate,代码行数:36,代码来源:OneTimeETagGenerationFilter.java

示例2: InvokerHttpRequest

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
/**
 * Construct a new wrapped request around the specified servlet request.
 *
 * @param request The servlet request being wrapped
 */
public InvokerHttpRequest(HttpServletRequest request) {

    super(request);
    this.pathInfo = request.getPathInfo();
    this.pathTranslated = request.getPathTranslated();
    this.requestURI = request.getRequestURI();
    this.servletPath = request.getServletPath();

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:InvokerHttpRequest.java

示例3: ServletRequestCopy

import javax.servlet.http.HttpServletRequest; //导入方法依赖的package包/类
public ServletRequestCopy(HttpServletRequest request) {
	this.servletPath = request.getServletPath();
	this.contextPath = request.getContextPath();
	this.pathInfo = request.getPathInfo();
	this.requestUri = request.getRequestURI();
	this.requestURL = request.getRequestURL();
	this.method = request.getMethod();
	this.serverName = request.getServerName();
	this.serverPort = request.getServerPort();
	this.protocol = request.getProtocol();
	this.scheme = request.getScheme();
	
	
	/*
	 * have to comment out below two lines as otherwise web socket will
	 * report UnSupportedOperationException upon connection
	 */
	//this.characterEncoding = request.getCharacterEncoding();
	//this.contentType = request.getContentType();
	//this.requestedSessionId = request.getRequestedSessionId();
	this.characterEncoding = null;
	this.contentType = null;
	this.requestedSessionId = null;
	
	this.locale = request.getLocale();
	this.locales = request.getLocales();
	this.isSecure = request.isSecure();
	this.remoteUser = request.getRemoteUser();
	this.remoteAddr = request.getRemoteAddr();
	this.remoteHost = request.getRemoteHost();
	this.remotePort = request.getRemotePort();
	this.localAddr = request.getLocalAddr();
	this.localName = request.getLocalName();
	this.localPort = request.getLocalPort();
	this.pathTranslated = request.getPathTranslated();
	this.principal = request.getUserPrincipal();

	HttpSession session = request.getSession(true);
	httpSession = new HttpSessionCopy(session);

	String s;
	Enumeration<String> e = request.getHeaderNames();
	while (e != null && e.hasMoreElements()) {
		s = e.nextElement();
		Enumeration<String> headerValues = request.getHeaders(s);
		this.headers.put(s, headerValues);
	}

	e = request.getAttributeNames();
	while (e != null && e.hasMoreElements()) {
		s = e.nextElement();
		attributes.put(s, request.getAttribute(s));
	}

	e = request.getParameterNames();
	while (e != null && e.hasMoreElements()) {
		s = e.nextElement();
		parameters.put(s, request.getParameterValues(s));
	}
}
 
开发者ID:jmfgdev,项目名称:gitplex-mit,代码行数:61,代码来源:ServletRequestCopy.java


注:本文中的javax.servlet.http.HttpServletRequest.getPathTranslated方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。