Java Code Examples for org.springframework.http.HttpCookie#getValue()

The following examples show how to use org.springframework.http.HttpCookie#getValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CookieValueMethodArgumentResolver.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
protected Object resolveNamedValue(String name, MethodParameter parameter, ServerWebExchange exchange) {
	HttpCookie cookie = exchange.getRequest().getCookies().getFirst(name);
	Class<?> paramType = parameter.getNestedParameterType();
	if (HttpCookie.class.isAssignableFrom(paramType)) {
		return cookie;
	}
	return (cookie != null ? cookie.getValue() : null);
}
 
Example 2
Source File: CookieValueMethodArgumentResolver.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
protected Object resolveNamedValue(String name, MethodParameter parameter, ServerWebExchange exchange) {
	HttpCookie cookie = exchange.getRequest().getCookies().getFirst(name);
	Class<?> paramType = parameter.getNestedParameterType();
	if (HttpCookie.class.isAssignableFrom(paramType)) {
		return cookie;
	}
	return (cookie != null ? cookie.getValue() : null);
}
 
Example 3
Source File: WebfluxSsoClient.java    From bird-java with MIT License 5 votes vote down vote up
/**
 * 从request中获取token
 *
 * @param exchange exchange
 * @return token
 */
public String getToken(ServerWebExchange exchange) {
    ServerHttpRequest request = exchange.getRequest();
    String token = request.getHeaders().getFirst(clientProperties.getCookieName());

    if (StringUtils.isBlank(token)) {
        HttpCookie cookie = request.getCookies().getFirst(clientProperties.getCookieName());
        if (cookie != null) {
            token = cookie.getValue();
        }
    }
    return token;
}