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 fcf017a5..47fc5546 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 735b68e0..bcd35a0a 100644 --- a/modules/core/src/main/resources/config/jeesite-core.yml +++ b/modules/core/src/main/resources/config/jeesite-core.yml @@ -657,7 +657,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 @@ -719,7 +719,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 9ba5ed6c..17634cfb 100644 --- a/web-api/src/main/resources/config/application.yml +++ b/web-api/src/main/resources/config/application.yml @@ -804,7 +804,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/ @@ -863,7 +863,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 dfe1fac9..21918bc0 100644 --- a/web/src/main/resources/config/application.yml +++ b/web/src/main/resources/config/application.yml @@ -804,7 +804,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/ @@ -863,7 +863,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, #