From 75e5e2765cb773f939e46888cd5ce940ef62ff38 Mon Sep 17 00:00:00 2001 From: thinkgem Date: Thu, 25 Jul 2024 11:53:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20webp=20=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jeesite/common/web/http/ServletUtils.java | 19 ++++--------------- .../main/resources/config/jeesite-core.yml | 4 ++-- .../views/htmltags/form/fileupload.html | 2 +- .../src/main/resources/config/application.yml | 4 ++-- web/src/main/resources/config/application.yml | 4 ++-- 5 files changed, 11 insertions(+), 22 deletions(-) diff --git a/common/src/main/java/com/jeesite/common/web/http/ServletUtils.java b/common/src/main/java/com/jeesite/common/web/http/ServletUtils.java index 3dc380c5..857a5f47 100644 --- a/common/src/main/java/com/jeesite/common/web/http/ServletUtils.java +++ b/common/src/main/java/com/jeesite/common/web/http/ServletUtils.java @@ -64,13 +64,8 @@ public class ServletUtils { * */ public static HttpServletRequest getRequest(){ - HttpServletRequest request = null; try{ - request = ((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest(); - if (request == null){ - return null; - } - return request; + return ((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getRequest(); }catch(Exception e){ return null; } @@ -83,16 +78,11 @@ public class ServletUtils { * requestContextFilter/* */ public static HttpServletResponse getResponse(){ - HttpServletResponse response = null; try{ - response = ((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getResponse(); - if (response == null){ - return null; - } + return ((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes()).getResponse(); }catch(Exception e){ return null; } - return response; } /** @@ -122,9 +112,8 @@ public class ServletUtils { public static boolean isStaticFile(String uri){ if (STATIC_FILE == null){ try { - throw new Exception("检测到“application.yml”中没有配置“web.staticFile”属性。" - + "配置示例:\n#静态文件后缀\nweb.staticFile=.css,.js,.png,.jpg,.gif," - + ".jpeg,.bmp,.ico,.swf,.psd,.htc,.crx,.xpi,.exe,.ipa,.apk"); + throw new Exception("检测到“application.yml”中没有配置“web.staticFile”属性。配置示例:\n#静态文件后缀\nweb.staticFile=" + + ".css,.js,.map,.png,.jpg,.gif,.jpeg,.webp,.bmp,.ico,.swf,.psd,.htc,.crx,.xpi,.exe,.ipa,.apk,.otf,.eot,.svg,.ttf,.woff,.woff2"); } catch (Exception e) { e.printStackTrace(); } diff --git a/modules/core/src/main/resources/config/jeesite-core.yml b/modules/core/src/main/resources/config/jeesite-core.yml index b15bec09..cca6a748 100644 --- a/modules/core/src/main/resources/config/jeesite-core.yml +++ b/modules/core/src/main/resources/config/jeesite-core.yml @@ -660,7 +660,7 @@ web: excludePathPatterns: ~ # 静态文件后缀,过滤静态文件,以提高访问性能。 - staticFile: .css,.js,.map,.png,.jpg,.gif,.jpeg,.bmp,.ico,.swf,.psd,.htc,.crx,.xpi,.exe,.ipa,.apk,.otf,.eot,.svg,.ttf,.woff,.woff2 + staticFile: .css,.js,.map,.png,.jpg,.gif,.jpeg,.webp,.bmp,.ico,.swf,.psd,.htc,.crx,.xpi,.exe,.ipa,.apk,.otf,.eot,.svg,.ttf,.woff,.woff2 # 静态资源缓存周期 Cache-Control,单位秒,1年 staticCachePeriod: 31536000 @@ -722,7 +722,7 @@ file: maxFileSize: '500*1024*1024' # 设置允许上传的文件后缀(全局设置) - imageAllowSuffixes: .gif,.bmp,.jpeg,.jpg,.ico,.png,.tif,.tiff, + imageAllowSuffixes: .gif,.bmp,.jpeg,.jpg,.ico,.png,.tif,.tiff,webp, mediaAllowSuffixes: .flv,.swf,.mkv,webm,.mid,.mov,.mp3,.mp4,.m4v,.mpc,.mpeg,.mpg,.swf,.wav,.wma,.wmv,.avi,.rm,.rmi,.rmvb,.aiff,.asf,.ogg,.ogv, fileAllowSuffixes: .doc,.docx,.rtf,.xls,.xlsx,.csv,.ppt,.pptx,.pdf,.vsd,.txt,.md,.xml,.rar,.zip,.7z,.tar,.tgz,.jar,.gz,.gzip,.bz2,.cab,.iso,.ipa,.apk, diff --git a/modules/core/src/main/resources/views/htmltags/form/fileupload.html b/modules/core/src/main/resources/views/htmltags/form/fileupload.html index 3e27b6f4..19aa2a22 100644 --- a/modules/core/src/main/resources/views/htmltags/form/fileupload.html +++ b/modules/core/src/main/resources/views/htmltags/form/fileupload.html @@ -163,7 +163,7 @@ $(function() { fileNameInputId: '${p.fileNameInputId}', uploadType: '${p.uploadType}', maxFileSize: "#{isNotBlank(p.maxFileSize)?p.maxFileSize:@Global.getConfig('file.maxFileSize', '500*1024*1024')}", - imageAllowSuffixes: '${isNotBlank(p.allowSuffixes)?p.allowSuffixes:@Global.getConfig("file.imageAllowSuffixes", ".gif,.bmp,.jpeg,.jpg,.ico,.png,.tif,.tiff,")}', + imageAllowSuffixes: '${isNotBlank(p.allowSuffixes)?p.allowSuffixes:@Global.getConfig("file.imageAllowSuffixes", ".gif,.bmp,.jpeg,.jpg,.ico,.png,.tif,.tiff,webp,")}', mediaAllowSuffixes: '${isNotBlank(p.allowSuffixes)?p.allowSuffixes:@Global.getConfig("file.mediaAllowSuffixes", ".flv,.swf,.mkv,webm,.mid,.mov,.mp3,.mp4,.m4v,.mpc,.mpeg,.mpg,.swf,.wav,.wma,.wmv,.avi,.rm,.rmi,.rmvb,.aiff,.asf,.ogg,.ogv,")}', fileAllowSuffixes: '${isNotBlank(p.allowSuffixes)?p.allowSuffixes:@Global.getConfig("file.fileAllowSuffixes", ".doc,.docx,.rtf,.xls,.xlsx,.csv,.ppt,.pptx,.pdf,.vsd,.txt,.md,.xml,.rar,.zip,.7z,.tar,.tgz,.jar,.gz,.gzip,.bz2,.cab,.iso,")}', chunked: "#{__info_type=='0'?false:@Global.getConfig('file.chunked', 'true')}", diff --git a/web-api/src/main/resources/config/application.yml b/web-api/src/main/resources/config/application.yml index 4223709d..8bd38297 100644 --- a/web-api/src/main/resources/config/application.yml +++ b/web-api/src/main/resources/config/application.yml @@ -801,7 +801,7 @@ web: excludePathPatterns: ~ # # 静态文件后缀,过滤静态文件,以提高访问性能。 -# staticFile: .css,.js,.map,.png,.jpg,.gif,.jpeg,.bmp,.ico,.swf,.psd,.htc,.crx,.xpi,.exe,.ipa,.apk,.otf,.eot,.svg,.ttf,.woff,.woff2 +# staticFile: .css,.js,.map,.png,.jpg,.gif,.jpeg,.webp,.bmp,.ico,.swf,.psd,.htc,.crx,.xpi,.exe,.ipa,.apk,.otf,.eot,.svg,.ttf,.woff,.woff2 # # # 静态文件后缀,排除的url路径,指定哪些uri路径不进行静态文件过滤。 # staticFileExcludeUri: /druid/ @@ -860,7 +860,7 @@ file: # maxFileSize: '500*1024*1024' # # # 设置允许上传的文件后缀(全局设置) -# imageAllowSuffixes: .gif,.bmp,.jpeg,.jpg,.ico,.png,.tif,.tiff, +# imageAllowSuffixes: .gif,.bmp,.jpeg,.jpg,.ico,.png,.tif,.tiff,webp, # mediaAllowSuffixes: .flv,.swf,.mkv,webm,.mid,.mov,.mp3,.mp4,.m4v,.mpc,.mpeg,.mpg,.swf,.wav,.wma,.wmv,.avi,.rm,.rmi,.rmvb,.aiff,.asf,.ogg,.ogv, # fileAllowSuffixes: .doc,.docx,.rtf,.xls,.xlsx,.csv,.ppt,.pptx,.pdf,.vsd,.txt,.md,.xml,.rar,.zip,.7z,.tar,.tgz,.jar,.gz,.gzip,.bz2,.cab,.iso,.ipa,.apk, # diff --git a/web/src/main/resources/config/application.yml b/web/src/main/resources/config/application.yml index db8c421e..c542a2cd 100644 --- a/web/src/main/resources/config/application.yml +++ b/web/src/main/resources/config/application.yml @@ -801,7 +801,7 @@ web: excludePathPatterns: ~ # # 静态文件后缀,过滤静态文件,以提高访问性能。 -# staticFile: .css,.js,.map,.png,.jpg,.gif,.jpeg,.bmp,.ico,.swf,.psd,.htc,.crx,.xpi,.exe,.ipa,.apk,.otf,.eot,.svg,.ttf,.woff,.woff2 +# staticFile: .css,.js,.map,.png,.jpg,.gif,.jpeg,.webp,.bmp,.ico,.swf,.psd,.htc,.crx,.xpi,.exe,.ipa,.apk,.otf,.eot,.svg,.ttf,.woff,.woff2 # # # 静态文件后缀,排除的url路径,指定哪些uri路径不进行静态文件过滤。 # staticFileExcludeUri: /druid/ @@ -860,7 +860,7 @@ file: # maxFileSize: '500*1024*1024' # # # 设置允许上传的文件后缀(全局设置) -# imageAllowSuffixes: .gif,.bmp,.jpeg,.jpg,.ico,.png,.tif,.tiff, +# imageAllowSuffixes: .gif,.bmp,.jpeg,.jpg,.ico,.png,.tif,.tiff,webp, # mediaAllowSuffixes: .flv,.swf,.mkv,webm,.mid,.mov,.mp3,.mp4,.m4v,.mpc,.mpeg,.mpg,.swf,.wav,.wma,.wmv,.avi,.rm,.rmi,.rmvb,.aiff,.asf,.ogg,.ogv, # fileAllowSuffixes: .doc,.docx,.rtf,.xls,.xlsx,.csv,.ppt,.pptx,.pdf,.vsd,.txt,.md,.xml,.rar,.zip,.7z,.tar,.tgz,.jar,.gz,.gzip,.bz2,.cab,.iso,.ipa,.apk, #