org.springframework.util.StringUtils#uriDecode ( )源码实例Demo

下面列出了org.springframework.util.StringUtils#uriDecode ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。


@Override
public Mono<Resource> apply(ServerRequest request) {
	PathContainer pathContainer = request.pathContainer();
	if (!this.pattern.matches(pathContainer)) {
		return Mono.empty();
	}

	pathContainer = this.pattern.extractPathWithinPattern(pathContainer);
	String path = processPath(pathContainer.value());
	if (path.contains("%")) {
		path = StringUtils.uriDecode(path, StandardCharsets.UTF_8);
	}
	if (!StringUtils.hasLength(path) || isInvalidPath(path)) {
		return Mono.empty();
	}

	try {
		Resource resource = this.location.createRelative(path);
		if (resource.exists() && resource.isReadable() && isResourceUnderLocation(resource)) {
			return Mono.just(resource);
		}
		else {
			return Mono.empty();
		}
	}
	catch (IOException ex) {
		throw new UncheckedIOException(ex);
	}
}
 

@Override
public Optional<Resource> apply(ServerRequest request) {
	PathContainer pathContainer = request.pathContainer();
	if (!this.pattern.matches(pathContainer)) {
		return Optional.empty();
	}

	pathContainer = this.pattern.extractPathWithinPattern(pathContainer);
	String path = processPath(pathContainer.value());
	if (path.contains("%")) {
		path = StringUtils.uriDecode(path, StandardCharsets.UTF_8);
	}
	if (!StringUtils.hasLength(path) || isInvalidPath(path)) {
		return Optional.empty();
	}

	try {
		Resource resource = this.location.createRelative(path);
		if (resource.exists() && resource.isReadable() && isResourceUnderLocation(resource)) {
			return Optional.of(resource);
		}
		else {
			return Optional.empty();
		}
	}
	catch (IOException ex) {
		throw new UncheckedIOException(ex);
	}
}
 

@Override
public Mono<Resource> apply(ServerRequest request) {
	PathContainer pathContainer = request.pathContainer();
	if (!this.pattern.matches(pathContainer)) {
		return Mono.empty();
	}

	pathContainer = this.pattern.extractPathWithinPattern(pathContainer);
	String path = processPath(pathContainer.value());
	if (path.contains("%")) {
		path = StringUtils.uriDecode(path, StandardCharsets.UTF_8);
	}
	if (!StringUtils.hasLength(path) || isInvalidPath(path)) {
		return Mono.empty();
	}

	try {
		Resource resource = this.location.createRelative(path);
		if (resource.exists() && resource.isReadable() && isResourceUnderLocation(resource)) {
			return Mono.just(resource);
		}
		else {
			return Mono.empty();
		}
	}
	catch (IOException ex) {
		throw new UncheckedIOException(ex);
	}
}
 
源代码4 项目: mica   文件: $.java

/**
 * url 解码
 *
 * @param source the encoded String
 * @return the decoded value
 * @throws IllegalArgumentException when the given source contains invalid encoded sequences
 * @see StringUtils#uriDecode(String, Charset)
 * @see java.net.URLDecoder#decode(String, String)
 */
public static String urlDecode(String source) {
	return StringUtils.uriDecode(source, Charsets.UTF_8);
}
 
源代码5 项目: mica   文件: $.java

/**
 * url 解码
 *
 * @param source  the encoded String
 * @param charset the character encoding to use
 * @return the decoded value
 * @throws IllegalArgumentException when the given source contains invalid encoded sequences
 * @see StringUtils#uriDecode(String, Charset)
 * @see java.net.URLDecoder#decode(String, String)
 */
public static String urlDecode(String source, Charset charset) {
	return StringUtils.uriDecode(source, charset);
}
 
源代码6 项目: spring-analysis-note   文件: UriUtils.java

/**
 * Decode the given encoded URI component.
 * <p>See {@link StringUtils#uriDecode(String, Charset)} for the decoding rules.
 * @param source the encoded String
 * @param encoding the character encoding to use
 * @return the decoded value
 * @throws IllegalArgumentException when the given source contains invalid encoded sequences
 * @see StringUtils#uriDecode(String, Charset)
 * @see java.net.URLDecoder#decode(String, String)
 */
public static String decode(String source, String encoding) {
	return StringUtils.uriDecode(source, Charset.forName(encoding));
}
 
源代码7 项目: spring-analysis-note   文件: UriUtils.java

/**
 * Decode the given encoded URI component.
 * <p>See {@link StringUtils#uriDecode(String, Charset)} for the decoding rules.
 * @param source the encoded String
 * @param charset the character encoding to use
 * @return the decoded value
 * @throws IllegalArgumentException when the given source contains invalid encoded sequences
 * @since 5.0
 * @see StringUtils#uriDecode(String, Charset)
 * @see java.net.URLDecoder#decode(String, String)
 */
public static String decode(String source, Charset charset) {
	return StringUtils.uriDecode(source, charset);
}
 
源代码8 项目: java-technology-stack   文件: UriUtils.java

/**
 * Decode the given encoded URI component.
 * <p>See {@link StringUtils#uriDecode(String, Charset)} for the decoding rules.
 * @param source the encoded String
 * @param encoding the character encoding to use
 * @return the decoded value
 * @throws IllegalArgumentException when the given source contains invalid encoded sequences
 * @see StringUtils#uriDecode(String, Charset)
 * @see java.net.URLDecoder#decode(String, String)
 */
public static String decode(String source, String encoding) {
	return StringUtils.uriDecode(source, Charset.forName(encoding));
}
 
源代码9 项目: java-technology-stack   文件: UriUtils.java

/**
 * Decode the given encoded URI component.
 * <p>See {@link StringUtils#uriDecode(String, Charset)} for the decoding rules.
 * @param source the encoded String
 * @param charset the character encoding to use
 * @return the decoded value
 * @throws IllegalArgumentException when the given source contains invalid encoded sequences
 * @since 5.0
 * @see StringUtils#uriDecode(String, Charset)
 * @see java.net.URLDecoder#decode(String, String)
 */
public static String decode(String source, Charset charset) {
	return StringUtils.uriDecode(source, charset);
}
 
源代码10 项目: blade-tool   文件: Func.java

/**
 * Decode the given encoded URI component.
 * <p>See {@link StringUtils#uriDecode(String, Charset)} for the decoding rules.
 *
 * @param source the encoded String
 * @return the decoded value
 * @throws IllegalArgumentException when the given source contains invalid encoded sequences
 * @see StringUtils#uriDecode(String, Charset)
 * @see java.net.URLDecoder#decode(String, String)
 */
public static String decode(String source) {
	return StringUtils.uriDecode(source, Charsets.UTF_8);
}
 
源代码11 项目: blade-tool   文件: Func.java

/**
 * Decode the given encoded URI component.
 * <p>See {@link StringUtils#uriDecode(String, Charset)} for the decoding rules.
 *
 * @param source  the encoded String
 * @param charset the character encoding to use
 * @return the decoded value
 * @throws IllegalArgumentException when the given source contains invalid encoded sequences
 * @see StringUtils#uriDecode(String, Charset)
 * @see java.net.URLDecoder#decode(String, String)
 */
public static String decode(String source, Charset charset) {
	return StringUtils.uriDecode(source, charset);
}