本文整理匯總了Java中org.springframework.web.util.UrlPathHelper.getOriginatingContextPath方法的典型用法代碼示例。如果您正苦於以下問題:Java UrlPathHelper.getOriginatingContextPath方法的具體用法?Java UrlPathHelper.getOriginatingContextPath怎麽用?Java UrlPathHelper.getOriginatingContextPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.web.util.UrlPathHelper
的用法示例。
在下文中一共展示了UrlPathHelper.getOriginatingContextPath方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getURI
import org.springframework.web.util.UrlPathHelper; //導入方法依賴的package包/類
/**
* 獲得第三個路徑分隔符的位置
*
* @param request
* @throws IllegalStateException
* 訪問路徑錯誤,沒有三(四)個'/'
*/
private static String getURI(HttpServletRequest request)
throws IllegalStateException {
UrlPathHelper helper = new UrlPathHelper();
String uri = helper.getOriginatingRequestUri(request);
String ctxPath = helper.getOriginatingContextPath(request);
int start = 0, i = 0, count = 2;
if (!StringUtils.isBlank(ctxPath)) {
count++;
}
while (i < count && start != -1) {
start = uri.indexOf('/', start + 1);
i++;
}
if (start <= 0) {
throw new IllegalStateException(
"admin access path not like '/jeeadmin/jeecms/...' pattern: "
+ uri);
}
return uri.substring(start);
}
示例2: getURI
import org.springframework.web.util.UrlPathHelper; //導入方法依賴的package包/類
/**
* 獲得第三個路徑分隔符的位置
*
* @param request
* @throws IllegalStateException
* 訪問路徑錯誤,沒有三(四)個'/'
*/
private static String getURI(HttpServletRequest request)
throws IllegalStateException {
UrlPathHelper helper = new UrlPathHelper();
String uri = helper.getOriginatingRequestUri(request);
String ctxPath = helper.getOriginatingContextPath(request);
int start = 0, i = 0, count = 2;
if (!StringUtils.isBlank(ctxPath)) {
count++;
}
while (i < count && start != -1) {
start = uri.indexOf('/', start + 1);
i++;
}
if (start <= 0) {
throw new IllegalStateException(
"admin access path not like '/jeeadmin/jspgou/...' pattern: "
+ uri);
}
return uri.substring(start);
}
示例3: getURI
import org.springframework.web.util.UrlPathHelper; //導入方法依賴的package包/類
public static String getURI(HttpServletRequest request) {
UrlPathHelper helper = new UrlPathHelper();
String uri = helper.getOriginatingRequestUri(request);
String ctx = helper.getOriginatingContextPath(request);
if (!StringUtils.isBlank(ctx)) {
return uri.substring(ctx.length());
} else {
return uri;
}
}
示例4: getURI
import org.springframework.web.util.UrlPathHelper; //導入方法依賴的package包/類
private static String getURI(HttpServletRequest request) {
UrlPathHelper helper = new UrlPathHelper();
String uri = helper.getOriginatingRequestUri(request);
String ctx = helper.getOriginatingContextPath(request);
if (!StringUtils.isBlank(ctx)) {
return uri.substring(ctx.length());
} else {
return uri;
}
}
示例5: expandBestMatchingPatternMulti
import org.springframework.web.util.UrlPathHelper; //導入方法依賴的package包/類
/**
* 自動尋找matchingPatternPath 擴充模板值.
*
* <p>
* urlPathHelper.getOriginatingContextPath(request) + expandUrl + (Validator.isNotNull(queryString) ? "?" + queryString : "");
* <p>
*
* @param request
* the request
* @param variableName
* 模板變量
* @param value
* the value
* @param valueSeparator
* 多值,分隔符
* @return 獲得一個新的url,參數部分會被原樣返回<br>
* urlPathHelper.getOriginatingContextPath(request) + expandUrl + (Validator.isNotNull(queryString) ? "?" + queryString : "");
*/
public static String expandBestMatchingPatternMulti(HttpServletRequest request,String variableName,String value,String valueSeparator){
String requestPath = RequestUtil.getOriginatingServletPath(request);
String matchingPatternPath = UriTemplateUtil.getBestMatchingPattern(request);//TODO 這種方法可能不太好 可能被覆蓋
String expandUrl = expandWithMultiVariable(requestPath, matchingPatternPath, variableName, value, valueSeparator);
if (LOGGER.isDebugEnabled()){
LOGGER.debug(JsonUtil.format(UrlPathHelperUtil.getUrlPathHelperMapForLog(request)));
}
String queryString = request.getQueryString();
UrlPathHelper urlPathHelper = new UrlPathHelper();
return urlPathHelper.getOriginatingContextPath(request) + expandUrl + (isNullOrEmpty(queryString) ? "?" + queryString : "");
}
示例6: expandBestMatchingPattern
import org.springframework.web.util.UrlPathHelper; //導入方法依賴的package包/類
/**
* 自動尋找matchingPatternPath 擴充模板值.
*
* <p>
* urlPathHelper.getOriginatingContextPath(request) + expandUrl + (Validator.isNotNull(queryString) ? "?" + queryString : "");
* </p>
*
* @param request
* the request
* @param variableName
* 模板變量
* @param value
* the value
* @return 獲得一個新的url,參數部分會被原樣返回<br>
* urlPathHelper.getOriginatingContextPath(request) + expandUrl + (Validator.isNotNull(queryString) ? "?" + queryString : "");
*
* @see #getBestMatchingPattern(HttpServletRequest)
* @see RequestUtil#getOriginatingServletPath(HttpServletRequest)
*/
public static String expandBestMatchingPattern(HttpServletRequest request,String variableName,String value){
String requestPath = RequestUtil.getOriginatingServletPath(request);
String matchingPatternPath = getBestMatchingPattern(request);// 這種方法可能不太好 可能被覆蓋
String expandUrl = expandWithVariable(requestPath, matchingPatternPath, variableName, value);
if (LOGGER.isDebugEnabled()){
LOGGER.debug(JsonUtil.format(UrlPathHelperUtil.getUrlPathHelperMapForLog(request)));
}
String queryString = request.getQueryString();
UrlPathHelper urlPathHelper = new UrlPathHelper();
return urlPathHelper.getOriginatingContextPath(request) + expandUrl + (isNullOrEmpty(queryString) ? "?" + queryString : "");
}