From b42a8176cab314e46c5c3d2593dd4826addd7cc0 Mon Sep 17 00:00:00 2001 From: RuoYi <yzz_ivy@163.com> Date: 星期日, 17 四月 2022 10:29:12 +0800 Subject: [PATCH] 设置分页参数默认值 --- ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java | 30 ++++++++++++++++++++---------- 1 files changed, 20 insertions(+), 10 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java index 9e6fd59..d67b246 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java @@ -49,6 +49,22 @@ } /** + * 获取Boolean参数 + */ + public static Boolean getParameterToBool(String name) + { + return Convert.toBool(getRequest().getParameter(name)); + } + + /** + * 获取Boolean参数 + */ + public static Boolean getParameterToBool(String name, Boolean defaultValue) + { + return Convert.toBool(getRequest().getParameter(name), defaultValue); + } + + /** * 获取request */ public static HttpServletRequest getRequest() @@ -83,9 +99,8 @@ * * @param response 渲染对象 * @param string 待渲染的字符串 - * @return null */ - public static String renderString(HttpServletResponse response, String string) + public static void renderString(HttpServletResponse response, String string) { try { @@ -98,7 +113,6 @@ { e.printStackTrace(); } - return null; } /** @@ -109,13 +123,13 @@ public static boolean isAjaxRequest(HttpServletRequest request) { String accept = request.getHeader("accept"); - if (accept != null && accept.indexOf("application/json") != -1) + if (accept != null && accept.contains("application/json")) { return true; } String xRequestedWith = request.getHeader("X-Requested-With"); - if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1) + if (xRequestedWith != null && xRequestedWith.contains("XMLHttpRequest")) { return true; } @@ -127,10 +141,6 @@ } String ajax = request.getParameter("__ajax"); - if (StringUtils.inStringIgnoreCase(ajax, "json", "xml")) - { - return true; - } - return false; + return StringUtils.inStringIgnoreCase(ajax, "json", "xml"); } } -- Gitblit v1.9.2