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


Java UriUtils.decode方法代碼示例

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


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

示例1: createRequestBuilderWithMethodAndUri

import org.springframework.web.util.UriUtils; //導入方法依賴的package包/類
protected MockHttpServletRequestBuilder createRequestBuilderWithMethodAndUri(Pact.InteractionRequest request) throws Exception {
    String uri = request.getUri().contains(getServletContextPathWithoutTrailingSlash())
            ? StringUtils.substringAfter(request.getUri(), getServletContextPathWithoutTrailingSlash())
            : request.getUri();
    uri = UriUtils.decode(uri, "UTF-8");

    switch (request.getMethod()) {
        case GET:
            return get(uri);
        case POST:
            return post(uri);
        case PUT:
            return put(uri);
        case DELETE:
            return delete(uri);
        default:
            throw new RuntimeException("Unsupported method " + request.getMethod());
    }
}
 
開發者ID:tyro,項目名稱:pact-spring-mvc,代碼行數:20,代碼來源:PactTestBase.java

示例2: fileOutputStream

import org.springframework.web.util.UriUtils; //導入方法依賴的package包/類
public void fileOutputStream(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {
    String filepath = req.getRequestURI();
    int index = filepath.indexOf(Global.USERFILES_BASE_URL);
    if (index >= 0) {
        filepath = filepath.substring(index + Global.USERFILES_BASE_URL.length());
    }
    try {
        filepath = UriUtils.decode(filepath, "UTF-8");
    } catch (UnsupportedEncodingException e1) {
        logger.error(String.format("解釋文件路徑失敗,URL地址為%s", filepath), e1);
    }
    File file = new File(Global.getUserfilesBaseDir() + Global.USERFILES_BASE_URL + filepath);
    try {
        FileCopyUtils.copy(new FileInputStream(file), resp.getOutputStream());
        resp.setHeader("Content-Type", "application/octet-stream");
        return;
    } catch (FileNotFoundException e) {
        req.setAttribute("exception", new FileNotFoundException("請求的文件不存在"));
        req.getRequestDispatcher("/WEB-INF/views/error/404.jsp").forward(req, resp);
    }
}
 
開發者ID:ansafari,項目名稱:melon,代碼行數:23,代碼來源:UserfilesDownloadServlet.java

示例3: getCallbackParam

import org.springframework.web.util.UriUtils; //導入方法依賴的package包/類
protected final String getCallbackParam(ServerHttpRequest request) {
	String query = request.getURI().getQuery();
	MultiValueMap<String, String> params = UriComponentsBuilder.newInstance().query(query).build().getQueryParams();
	String value = params.getFirst("c");
	if (StringUtils.isEmpty(value)) {
		return null;
	}
	try {
		String result = UriUtils.decode(value, "UTF-8");
		return (CALLBACK_PARAM_PATTERN.matcher(result).matches() ? result : null);
	}
	catch (UnsupportedEncodingException ex) {
		// should never happen
		throw new SockJsException("Unable to decode callback query parameter", null, ex);
	}
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:17,代碼來源:AbstractHttpSendingTransportHandler.java

示例4: fileOutputStream

import org.springframework.web.util.UriUtils; //導入方法依賴的package包/類
public void fileOutputStream(HttpServletRequest req, HttpServletResponse resp) 
		throws ServletException, IOException {
	String filepath = req.getRequestURI();
	int index = filepath.indexOf(Global.USERFILES_BASE_URL);
	if(index >= 0) {
		filepath = filepath.substring(index + Global.USERFILES_BASE_URL.length());
	}
	try {
		filepath = UriUtils.decode(filepath, "UTF-8");
	} catch (UnsupportedEncodingException e1) {
		logger.error(String.format("解釋文件路徑失敗,URL地址為%s", filepath), e1);
	}
	File file = new File(Global.getUserfilesBaseDir() + Global.USERFILES_BASE_URL + filepath);
	try {
		FileCopyUtils.copy(new FileInputStream(file), resp.getOutputStream());
		resp.setHeader("Content-Type", "application/octet-stream");
		return;
	} catch (FileNotFoundException e) {
		req.setAttribute("exception", new FileNotFoundException("請求的文件不存在"));
		req.getRequestDispatcher("/WEB-INF/views/error/404.jsp").forward(req, resp);
	}
}
 
開發者ID:EleTeam,項目名稱:Shop-for-JavaWeb,代碼行數:23,代碼來源:UserfilesDownloadServlet.java

示例5: copyQueryParams

import org.springframework.web.util.UriUtils; //導入方法依賴的package包/類
void copyQueryParams(UriComponents uriComponents, MockHttpServletRequest servletRequest){
	try {
		if (uriComponents.getQuery() != null) {
			String query = UriUtils.decode(uriComponents.getQuery(), UTF_8);
			servletRequest.setQueryString(query);
		}

		for (Entry<String, List<String>> entry : uriComponents.getQueryParams().entrySet()) {
			for (String value : entry.getValue()) {
				servletRequest.addParameter(
						UriUtils.decode(entry.getKey(), UTF_8),
						UriUtils.decode(value, UTF_8));
			}
		}
	}
	catch (UnsupportedEncodingException ex) {
		// shouldn't happen
	}
}
 
開發者ID:duchien85,項目名稱:netty-cookbook,代碼行數:20,代碼來源:ServletNettyChannelHandler.java

示例6: isDescendentOrEqual

import org.springframework.web.util.UriUtils; //導入方法依賴的package包/類
private static boolean isDescendentOrEqual(URL collection,
                                           URL test) {
    if(collection == null || test == null){
        return false;
    }
    if (collection.toString().equals(test.toString())) {
        return true;
    }
    
    try {
        String testPathDecoded = UriUtils.decode(test.getPath(), "UTF-8");
        String collectionPathDecoded = UriUtils.decode(collection.getPath(), "UTF-8");

        return testPathDecoded.startsWith(collectionPathDecoded);
    } catch (UnsupportedEncodingException e) {
        return test.getPath().startsWith(collection.getPath());
    }
}
 
開發者ID:ksokol,項目名稱:carldav,代碼行數:19,代碼來源:MultigetReport.java

示例7: unescapeUrlPart

import org.springframework.web.util.UriUtils; //導入方法依賴的package包/類
/**
 * Unescapes an already escaped url part so the server can query the original value
 */
public static String unescapeUrlPart(String part){
	if(part == null){
		return null;
	}
	
	try {
		return UriUtils.decode(part, "UTF-8");
	} 
	catch (UnsupportedEncodingException e) {
		e.printStackTrace();
	}
	
	return null;
}
 
開發者ID:KevinWorkman,項目名稱:StaticVoidGames,代碼行數:18,代碼來源:HtmlEscaper.java


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