public class WebUtils extends Object
Created by Roney on 2019/3/26 16:50
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
JSONP_CALLBACK_NAME
JSONP请求函数参数名
|
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
addParamsWithTimestamp(String url,
Object... args)
对URL增加参数,并且添加默认的时间戳
|
static Map<String,javax.servlet.http.Cookie> |
cookieMap(javax.servlet.http.HttpServletRequest request)
根据传入的request获取当前有效的cookieMap
|
static String |
getAbsUri(javax.servlet.http.HttpServletRequest req)
获取绝对URI
|
static String |
getAbsUrl(javax.servlet.http.HttpServletRequest req)
获取绝对地址
|
static String |
getAppUrl(javax.servlet.http.HttpServletRequest req)
获取应用根地址
|
static javax.servlet.http.Cookie |
getCookie(javax.servlet.http.HttpServletRequest req,
String name)
通过名字寻找Cookie
|
static String |
getIp(javax.servlet.http.HttpServletRequest request) |
static InetAddress |
getLocalAddress()
获得本机Ip
|
static Map<String,Object> |
getParameterMap(javax.servlet.http.HttpServletRequest request,
String charset)
将请求参数字符串转换为Map,可制定特定编码避免乱码
|
static Map<String,Object> |
getParameterMap(String queryString,
String charset)
将查询参数转换为Map
|
static <T> T |
getParameterObject(Class<T> type,
javax.servlet.http.HttpServletRequest request,
String charset)
将参数转换为制定类型的对象,可制定特定的编码来避免乱码
|
static <T> T |
getParameterObject(Class<T> type,
String queryString,
String charset)
将QueryString转换为对象
|
static String |
getParameterString(javax.servlet.http.HttpServletRequest request,
String charset)
获取参数字符串,包括queryString和post过来的那部分数据(Post时会关闭数据流,不可用于上传文件的请求的解析)
|
static PrintWriter |
getWriter(javax.servlet.http.HttpServletResponse response)
从response对象获取字符流写入器,无论response是否被调用过getOutputStream
|
static boolean |
isAjaxRequest(javax.servlet.http.HttpServletRequest request) |
public static Map<String,javax.servlet.http.Cookie> cookieMap(javax.servlet.http.HttpServletRequest request)
request - public static boolean isAjaxRequest(javax.servlet.http.HttpServletRequest request)
public static String getIp(javax.servlet.http.HttpServletRequest request)
public static PrintWriter getWriter(javax.servlet.http.HttpServletResponse response) throws IOException
response - IOExceptionpublic static String addParamsWithTimestamp(String url, Object... args) throws UnsupportedEncodingException
url - args - UnsupportedEncodingExceptionpublic static String getAbsUrl(javax.servlet.http.HttpServletRequest req)
req - public static String getAbsUri(javax.servlet.http.HttpServletRequest req)
req - public static String getAppUrl(javax.servlet.http.HttpServletRequest req)
req - public static javax.servlet.http.Cookie getCookie(javax.servlet.http.HttpServletRequest req,
String name)
req - name - public static <T> T getParameterObject(Class<T> type, String queryString, String charset)
type - queryString - charset - IllegalAccessExceptionInstantiationExceptionUnsupportedEncodingExceptionpublic static Map<String,Object> getParameterMap(String queryString, String charset)
queryString - charset - public static Map<String,Object> getParameterMap(javax.servlet.http.HttpServletRequest request, String charset) throws IOException
request - charset - IOExceptionpublic static <T> T getParameterObject(Class<T> type, javax.servlet.http.HttpServletRequest request, String charset) throws IOException
type - request - charset - IOExceptionpublic static String getParameterString(javax.servlet.http.HttpServletRequest request, String charset) throws IOException
request - charset - IOExceptionpublic static InetAddress getLocalAddress()
Copyright © 2024. All rights reserved.