diff --git a/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/CommonController.java b/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/CommonController.java index d7ad456a..3903d437 100644 --- a/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/CommonController.java +++ b/jero-boot-module-system/src/main/java/com/jero/modules/system/controller/CommonController.java @@ -12,6 +12,7 @@ import lombok.extern.slf4j.Slf4j; import com.jero.common.api.vo.Result; import com.jero.common.constant.CommonConstant; import com.jero.common.system.api.ISysBaseAPI; +import org.apache.commons.lang3.StringUtils; import org.apache.shiro.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -170,7 +171,10 @@ public class CommonController { response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"),"iso-8859-1")); response.setContentType("application/force-download");// 设置强制下载不打开 if (type == null) { - if (fileName.contains(".jpg") || fileName.contains(".png") || fileName.contains(".gif") || fileName.contains(".jpeg")) { + fileName = StringUtils.lowerCase(fileName); + if (fileName.contains(".jpg") || fileName.contains(".gif") || fileName.contains(".jpeg")) { + response.setContentType("image/jpeg;image/jpg;image/gif;image/png"); + } else if (fileName.contains(".png")) { response.setContentType("image/png;image/jpg;image/gif;image/jpeg"); } } @@ -279,7 +283,10 @@ public class CommonController { response.addHeader("Content-Disposition", "attachment;fileName=" + new String(fileName.getBytes("UTF-8"),"iso-8859-1")); response.setContentType("application/force-download");// 设置强制下载不打开 if (type == null) { - if (fileName.contains(".jpg") || fileName.contains(".png") || fileName.contains(".gif") || fileName.contains(".jpeg")) { + fileName = StringUtils.lowerCase(fileName); + if (fileName.contains(".jpg") || fileName.contains(".gif") || fileName.contains(".jpeg")) { + response.setContentType("image/jpeg;image/jpg;image/gif;image/png"); + } else if (fileName.contains(".png")) { response.setContentType("image/png;image/jpg;image/gif;image/jpeg"); } }