本文整理匯總了Java中javax.faces.context.ExternalContext.getRequestServletPath方法的典型用法代碼示例。如果您正苦於以下問題:Java ExternalContext.getRequestServletPath方法的具體用法?Java ExternalContext.getRequestServletPath怎麽用?Java ExternalContext.getRequestServletPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.faces.context.ExternalContext
的用法示例。
在下文中一共展示了ExternalContext.getRequestServletPath方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: _resolveSourceName
import javax.faces.context.ExternalContext; //導入方法依賴的package包/類
private String _resolveSourceName(
ExternalContext external,
String name)
{
// if the path is a full URI, get it so it's from the context root
if ( name.charAt(0) == '/' )
{
String contextPath = external.getRequestContextPath();
if ( name.regionMatches( 0, contextPath, 0, contextPath.length()))
{
name = name.substring ( contextPath.length());
}
else
{
if (_LOG.isWarning())
_LOG.warning("UNABLE_FLIP_ICON", new Object[]{name, contextPath});
}
}
// otherwise it must be a relative path and needs to be converted to
// a path from the context root.
else
{
String rootName = external.getRequestServletPath();
if (rootName != null)
{
int endIndex = rootName.lastIndexOf('/') + 1;
name = rootName.substring(0, endIndex ) + name;
}
}
return name;
}