public class WebUtils extends Object
Constructor and Description |
---|
WebUtils() |
Modifier and Type | Method and Description |
---|---|
static String |
appendQueryStr(HttpServletRequest request,
boolean encode) |
static String |
baseUrl(HttpServletRequest request) |
static IView |
buildErrorView(IWebMvc owner,
ErrorCode errorCode) |
static IView |
buildErrorView(IWebMvc owner,
ErrorCode errorCode,
String redirectUrl,
int timeInterval) |
static IView |
buildErrorView(IWebMvc owner,
int code,
String msg) |
static IView |
buildErrorView(IWebMvc owner,
int code,
String msg,
String redirectUrl,
int timeInterval) |
static IView |
buildErrorView(IWebMvc owner,
int code,
String msg,
String redirectUrl,
int timeInterval,
Map<String,Object> data) |
static IView |
buildErrorView(IWebMvc owner,
String resourceName,
ErrorCode errorCode) |
static IView |
buildErrorView(IWebMvc owner,
String resourceName,
ErrorCode errorCode,
String redirectUrl,
int timeInterval) |
static IView |
buildErrorView(IWebMvc owner,
String resourceName,
int code,
String msg,
String redirectUrl,
int timeInterval,
Map<String,Object> data) |
static IView |
buildErrorView(IWebMvc owner,
String resourceName,
String code,
String msg,
String redirectUrl,
int timeInterval,
Map<String,Object> data) |
static String |
buildRedirectUrl(IContext context,
HttpServletRequest request,
String redirectUrl,
boolean needPrefix) |
static String |
buildUrl(HttpServletRequest request,
String requestPath,
boolean withBasePath) |
static String |
decodeUrl(String url) |
static byte[] |
decryptStr(HttpServletRequest request,
byte[] bytes) |
static String |
decryptStr(HttpServletRequest request,
String dataStr)
内容解密(基于客户端IP和浏览器类型)
|
static String |
encodeUrl(String url) |
static String |
encryptStr(HttpServletRequest request,
byte[] bytes) |
static String |
encryptStr(HttpServletRequest request,
String dataStr)
内容加密(基于客户端IP和浏览器类型)
|
static String |
errorCodeI18n(IWebMvc owner,
IExceptionProcessor.Result result) |
static String |
errorCodeI18n(IWebMvc owner,
int code,
String defaultValue) |
static String |
errorCodeI18n(IWebMvc owner,
String resourceName,
IExceptionProcessor.Result result) |
static String |
errorCodeI18n(IWebMvc owner,
String resourceName,
int code,
String defaultValue) |
static String |
errorCodeI18n(IWebMvc owner,
String code,
String defaultValue) |
static String |
errorCodeI18n(IWebMvc owner,
String resourceName,
String code,
String defaultValue) |
static String |
fixUrl(String url,
boolean needStartWith,
boolean needEndWith)
Deprecated.
|
static String |
fixUrlWithProtocol(String url,
boolean needEndWith)
Deprecated.
|
static String |
getContextParamValue(IContext context,
String paramName,
String defaultValue) |
static IWebMvc |
getOwner() |
static String |
getRemoteAddress(HttpServletRequest request) |
static String[] |
getRemoteAddresses(HttpServletRequest request) |
static String |
httpStatusI18n(IWebMvc owner,
int code) |
static String |
httpStatusI18n(IWebMvc owner,
String resourceName,
int code) |
static String |
i18nStr(IWebMvc owner,
String resourceKey)
加载i18n资源键值
|
static String |
i18nStr(IWebMvc owner,
String resourceKey,
String defaultValue)
加载i18n资源键值
|
static String |
i18nStr(IWebMvc owner,
String resourceName,
String resourceKey,
String defaultValue) |
static String |
includeJsp(HttpServletRequest request,
HttpServletResponse response,
String jspFile,
String charsetEncoding) |
static void |
includeJsp(HttpServletRequest request,
HttpServletResponse response,
String jspFile,
String charsetEncoding,
OutputStream outputStream) |
static boolean |
isAccepted(HttpServletRequest request,
String contentType) |
static boolean |
isAjax(HttpServletRequest request) |
static boolean |
isCorsOptionsRequest(HttpServletRequest request) |
static boolean |
isCorsRequest(HttpServletRequest request) |
static boolean |
isJsonAccepted(HttpServletRequest request) |
static boolean |
isJsonAccepted(HttpServletRequest request,
String paramFormat) |
static boolean |
isJsonFormat(HttpServletRequest request) |
static boolean |
isJsonFormat(HttpServletRequest request,
String paramFormat) |
static boolean |
isPost(HttpServletRequest request) |
static boolean |
isWebSocket(HttpServletRequest request) |
static boolean |
isXmlAccepted(HttpServletRequest request) |
static boolean |
isXmlAccepted(HttpServletRequest request,
String paramFormat) |
static boolean |
isXmlFormat(HttpServletRequest request) |
static boolean |
isXmlFormat(HttpServletRequest request,
String paramFormat) |
static String |
messageWithTemplate(IApplication owner,
Collection<ValidateResult> messages) |
static String |
messageWithTemplate(IApplication owner,
String message) |
static String |
messageWithTemplate(IApplication owner,
String title,
Collection<ValidateResult> messages) |
static String |
messageWithTemplate(IApplication owner,
String name,
String message) |
static String |
redirectHeaderLocation(HttpServletResponse response,
String url) |
static String |
redirectHeaderRefresh(HttpServletResponse response,
String templateUrl,
int time,
String url) |
static String |
redirectJavaScript(String url) |
static String |
replaceRegClear(String source) |
static String |
replaceRegText(String source,
String key,
String value) |
public static IWebMvc getOwner()
public static String buildUrl(HttpServletRequest request, String requestPath, boolean withBasePath)
request
- HttpServletRequest对象requestPath
- 控制器路径withBasePath
- 是否采用完整路径(即非相对路径)public static String baseUrl(HttpServletRequest request)
request
- HttpServletRequest对象public static String appendQueryStr(HttpServletRequest request, boolean encode)
request
- HttpServletRequest对象encode
- 是否编码@Deprecated public static String fixUrl(String url, boolean needStartWith, boolean needEndWith)
url
- URL地址needStartWith
- 是否以'/'开始needEndWith
- 是否以'/'结束ParamUtils.fixUrl(String, boolean, boolean)
@Deprecated public static String fixUrlWithProtocol(String url, boolean needEndWith)
url
- URL地址needEndWith
- 是否必须以分隔符结束ParamUtils.fixUrlWithProtocol(String, boolean)
public static boolean isAjax(HttpServletRequest request)
request
- HttpServletRequest对象public static boolean isWebSocket(HttpServletRequest request)
public static boolean isCorsRequest(HttpServletRequest request)
public static boolean isCorsOptionsRequest(HttpServletRequest request)
public static boolean isAccepted(HttpServletRequest request, String contentType)
public static boolean isJsonAccepted(HttpServletRequest request)
public static boolean isJsonAccepted(HttpServletRequest request, String paramFormat)
public static boolean isJsonFormat(HttpServletRequest request)
public static boolean isJsonFormat(HttpServletRequest request, String paramFormat)
public static boolean isXmlAccepted(HttpServletRequest request)
public static boolean isXmlAccepted(HttpServletRequest request, String paramFormat)
public static boolean isXmlFormat(HttpServletRequest request)
public static boolean isXmlFormat(HttpServletRequest request, String paramFormat)
public static boolean isPost(HttpServletRequest request)
request
- HttpServletRequest对象public static String redirectJavaScript(String url)
url
- 目标URL地址public static String redirectHeaderLocation(HttpServletResponse response, String url)
response
- HttpServletResponse对象url
- 目标URL地址public static String redirectHeaderRefresh(HttpServletResponse response, String templateUrl, int time, String url)
response
- HttpServletResponse对象templateUrl
- JSP等模板文件URLtime
- 间隔时间url
- 页面URL地址,空为当前页面public static String getRemoteAddress(HttpServletRequest request)
request
- HttpServletRequest对象public static String[] getRemoteAddresses(HttpServletRequest request)
request
- HttpServletRequest对象public static String getContextParamValue(IContext context, String paramName, String defaultValue)
public static String replaceRegText(String source, String key, String value)
source
- 源字符串key
- 键value
- 值public static String includeJsp(HttpServletRequest request, HttpServletResponse response, String jspFile, String charsetEncoding) throws ServletException, IOException
request
- HttpServletRequest对象response
- HttpServletResponse对象jspFile
- JSP文件路径charsetEncoding
- 字符编码ServletException
- 可能产生的异常IOException
- 可能产生的异常public static void includeJsp(HttpServletRequest request, HttpServletResponse response, String jspFile, String charsetEncoding, OutputStream outputStream) throws ServletException, IOException
ServletException
IOException
public static String encryptStr(HttpServletRequest request, String dataStr) throws Exception
request
- HttpServletRequest对象dataStr
- 待加密的内容Exception
- 可能产生的异常public static String encryptStr(HttpServletRequest request, byte[] bytes) throws Exception
Exception
public static String decryptStr(HttpServletRequest request, String dataStr) throws Exception
request
- HttpServletRequest对象dataStr
- 待解密的内容Exception
- 可能产生的异常public static byte[] decryptStr(HttpServletRequest request, byte[] bytes) throws Exception
Exception
public static String messageWithTemplate(IApplication owner, String message)
public static String messageWithTemplate(IApplication owner, String name, String message)
public static String messageWithTemplate(IApplication owner, Collection<ValidateResult> messages)
public static String messageWithTemplate(IApplication owner, String title, Collection<ValidateResult> messages)
public static String buildRedirectUrl(IContext context, HttpServletRequest request, String redirectUrl, boolean needPrefix)
public static IView buildErrorView(IWebMvc owner, String resourceName, ErrorCode errorCode)
public static IView buildErrorView(IWebMvc owner, int code, String msg, String redirectUrl, int timeInterval)
public static IView buildErrorView(IWebMvc owner, ErrorCode errorCode, String redirectUrl, int timeInterval)
public static IView buildErrorView(IWebMvc owner, String resourceName, ErrorCode errorCode, String redirectUrl, int timeInterval)
public static IView buildErrorView(IWebMvc owner, int code, String msg, String redirectUrl, int timeInterval, Map<String,Object> data)
public static IView buildErrorView(IWebMvc owner, String resourceName, int code, String msg, String redirectUrl, int timeInterval, Map<String,Object> data)
public static IView buildErrorView(IWebMvc owner, String resourceName, String code, String msg, String redirectUrl, int timeInterval, Map<String,Object> data)
public static String i18nStr(IWebMvc owner, String resourceKey)
owner
- 所属容器resourceKey
- 键public static String i18nStr(IWebMvc owner, String resourceKey, String defaultValue)
owner
- 所属容器resourceKey
- 键defaultValue
- 默认值public static String i18nStr(IWebMvc owner, String resourceName, String resourceKey, String defaultValue)
public static String errorCodeI18n(IWebMvc owner, String resourceName, int code, String defaultValue)
public static String errorCodeI18n(IWebMvc owner, String resourceName, String code, String defaultValue)
public static String errorCodeI18n(IWebMvc owner, IExceptionProcessor.Result result)
public static String errorCodeI18n(IWebMvc owner, String resourceName, IExceptionProcessor.Result result)
Copyright © 2022. All rights reserved.