类 WebUtils
java.lang.Object
com.alibaba.nacos.core.utils.WebUtils
web utils.
- 作者:
- nkorange
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明static StringgetAcceptEncoding(javax.servlet.http.HttpServletRequest req)get accept encode from request.static StringgetUserAgent(javax.servlet.http.HttpServletRequest request)Returns the value of the request header "user-agent" as aString.static voidonFileUpload(org.springframework.web.multipart.MultipartFile multipartFile, Consumer<File> consumer, org.springframework.web.context.request.async.DeferredResult<com.alibaba.nacos.common.model.RestResult<String>> response)Handle file upload operations.static Stringget target value from parameterMap, if not found will return default value.static <T> voidprocess(org.springframework.web.context.request.async.DeferredResult<T> deferredResult, CompletableFuture<T> future, Runnable success, Function<Throwable,T> errorHandler)Register DeferredResult in the callback of CompletableFuture.static <T> voidprocess(org.springframework.web.context.request.async.DeferredResult<T> deferredResult, CompletableFuture<T> future, Function<Throwable,T> errorHandler)Register DeferredResult in the callback of CompletableFuture.static Stringget target value from parameterMap, if not found will throwIllegalArgumentException.static voidresponse data to client.
-
构造器详细资料
-
WebUtils
public WebUtils()
-
-
方法详细资料
-
required
get target value from parameterMap, if not found will throwIllegalArgumentException.- 参数:
req-HttpServletRequestkey- key- 返回:
- value
-
optional
public static String optional(javax.servlet.http.HttpServletRequest req, String key, String defaultValue)get target value from parameterMap, if not found will return default value.- 参数:
req-HttpServletRequestkey- keydefaultValue- default value- 返回:
- value
-
getAcceptEncoding
get accept encode from request.- 参数:
req-HttpServletRequest- 返回:
- accept encode
-
getUserAgent
Returns the value of the request header "user-agent" as aString.- 参数:
request- HttpServletRequest- 返回:
- the value of the request header "user-agent", or the value of the request header "client-version" if the request does not have a header of "user-agent".
-
response
public static void response(javax.servlet.http.HttpServletResponse response, String body, int code) throws IOExceptionresponse data to client.- 参数:
response-HttpServletResponsebody- bodycode- http code- 抛出:
IOException- IOException
-
onFileUpload
public static void onFileUpload(org.springframework.web.multipart.MultipartFile multipartFile, Consumer<File> consumer, org.springframework.web.context.request.async.DeferredResult<com.alibaba.nacos.common.model.RestResult<String>> response)Handle file upload operations.- 参数:
multipartFile- fileconsumer- post processorresponse-DeferredResult
-
process
public static <T> void process(org.springframework.web.context.request.async.DeferredResult<T> deferredResult, CompletableFuture<T> future, Function<Throwable,T> errorHandler)Register DeferredResult in the callback of CompletableFuture.- 类型参数:
T- target type- 参数:
deferredResult-DeferredResultfuture-CompletableFutureerrorHandler-Function
-
process
public static <T> void process(org.springframework.web.context.request.async.DeferredResult<T> deferredResult, CompletableFuture<T> future, Runnable success, Function<Throwable,T> errorHandler)Register DeferredResult in the callback of CompletableFuture.- 类型参数:
T- target type- 参数:
deferredResult-DeferredResultfuture-CompletableFuturesuccess- if future success, callback runnableerrorHandler-Function
-