From a907f8485c9d8bea82c71be7364c4c511e5e429a Mon Sep 17 00:00:00 2001 From: wzy1024 <395778325@qq.com> Date: 星期二, 04 四月 2023 11:58:26 +0800 Subject: [PATCH] 导出Excel,@Excel注解使用dictType属性时,如果有大量的字典数据,就会有大量的查询redis(打开、关闭),导致特别慢。于是使用map存储字典数据,相同的key就不需要再次去查询redis,大大提高了导出效率。 --- ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java b/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java index 6794394..e0cc40a 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java @@ -34,13 +34,13 @@ if (values != null) { int length = values.length; - String[] escapseValues = new String[length]; + String[] escapesValues = new String[length]; for (int i = 0; i < length; i++) { // 防xss攻击和过滤前后空格 - escapseValues[i] = EscapeUtil.clean(values[i]).trim(); + escapesValues[i] = EscapeUtil.clean(values[i]).trim(); } - return escapseValues; + return escapesValues; } return super.getParameterValues(name); } @@ -63,7 +63,8 @@ // xss过滤 json = EscapeUtil.clean(json).trim(); - final ByteArrayInputStream bis = new ByteArrayInputStream(json.getBytes("utf-8")); + byte[] jsonBytes = json.getBytes("utf-8"); + final ByteArrayInputStream bis = new ByteArrayInputStream(jsonBytes); return new ServletInputStream() { @Override @@ -76,6 +77,12 @@ public boolean isReady() { return true; + } + + @Override + public int available() throws IOException + { + return jsonBytes.length; } @Override @@ -99,6 +106,6 @@ public boolean isJsonRequest() { String header = super.getHeader(HttpHeaders.CONTENT_TYPE); - return MediaType.APPLICATION_JSON_VALUE.equalsIgnoreCase(header); + return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE); } } \ No newline at end of file -- Gitblit v1.9.2