| | |
| | | package com.ruoyi.common.utils; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.extra.servlet.ServletUtil; |
| | | import cn.hutool.http.HttpStatus; |
| | | import org.springframework.http.MediaType; |
| | |
| | | return Convert.toInt(getRequest().getParameter(name), defaultValue); |
| | | } |
| | | |
| | | /** |
| | | * 获取request |
| | | */ |
| | | public static HttpServletRequest getRequest() { |
| | | return getRequestAttributes().getRequest(); |
| | | } |
| | | /** |
| | | * 获取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() { |
| | | return getRequestAttributes().getRequest(); |
| | | } |
| | | |
| | | /** |
| | | * 获取response |
| | |
| | | } |
| | | |
| | | String uri = request.getRequestURI(); |
| | | if (StrUtil.equalsAnyIgnoreCase(uri, ".json", ".xml")) { |
| | | if (StringUtils.equalsAnyIgnoreCase(uri, ".json", ".xml")) { |
| | | return true; |
| | | } |
| | | |
| | | String ajax = request.getParameter("__ajax"); |
| | | if (StrUtil.equalsAnyIgnoreCase(ajax, "json", "xml")) { |
| | | if (StringUtils.equalsAnyIgnoreCase(ajax, "json", "xml")) { |
| | | return true; |
| | | } |
| | | return false; |