當前位置: 首頁>>代碼示例>>Java>>正文


Java ServletContext.getContext方法代碼示例

本文整理匯總了Java中javax.servlet.ServletContext.getContext方法的典型用法代碼示例。如果您正苦於以下問題:Java ServletContext.getContext方法的具體用法?Java ServletContext.getContext怎麽用?Java ServletContext.getContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.servlet.ServletContext的用法示例。


在下文中一共展示了ServletContext.getContext方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getServletContextAndPathFromVirtualPath

import javax.servlet.ServletContext; //導入方法依賴的package包/類
protected ServletContextAndPath getServletContextAndPathFromVirtualPath( String virtualPath ) throws IOException {
ServletContext servletContext = servlet.getServletContext();
String path = null;

if ( !virtualPath.startsWith("/") &&  !virtualPath.startsWith("\\") ) {
    path = getAbsolutePath( virtualPath );
} else {
    String normalized = SSIServletRequestUtil.normalize( virtualPath );
    if ( isVirtualWebappRelative ) {
	path = normalized;
    } else {
	servletContext = servletContext.getContext( normalized );
	if ( servletContext == null ) {
	    throw new IOException("Couldn't get context for path: " + normalized );
	}

	//If it's the root context, then there is no context element to remove, ie:
	// '/file1.shtml' vs '/appName1/file1.shtml'
	if ( !isRootContext( servletContext ) ) {
	    path = getPathWithoutContext( normalized );
	    if ( path == null ) {
		throw new IOException("Couldn't remove context from path: " + normalized );
	    }		    
	} else {
	    path = normalized;
	}
    }
}
return new ServletContextAndPath( servletContext, path );
   }
 
開發者ID:c-rainstorm,項目名稱:jerrydog,代碼行數:31,代碼來源:SSIServletExternalResolver.java

示例2: isRootContext

import javax.servlet.ServletContext; //導入方法依賴的package包/類
protected boolean isRootContext(ServletContext servletContext) {
    return servletContext == servletContext.getContext("/");
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:4,代碼來源:SSIServletExternalResolver.java

示例3: isRootContext

import javax.servlet.ServletContext; //導入方法依賴的package包/類
protected boolean isRootContext( ServletContext servletContext ) {
return servletContext == servletContext.getContext( "/" );
   }
 
開發者ID:c-rainstorm,項目名稱:jerrydog,代碼行數:4,代碼來源:SSIServletExternalResolver.java

示例4: isRootContext

import javax.servlet.ServletContext; //導入方法依賴的package包/類
protected boolean isRootContext(ServletContext servletContext) {
	return servletContext == servletContext.getContext("/");
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:4,代碼來源:SSIServletExternalResolver.java


注:本文中的javax.servlet.ServletContext.getContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。