1、121(新uat)环境配置

2、下载文件时头信息增加content-length
This commit is contained in:
1378012178@qq.com 2025-04-15 09:45:47 +08:00
parent 2be2ca36d0
commit 59bc47c6cc
4 changed files with 59 additions and 22 deletions

View File

@ -210,14 +210,14 @@ public class CommonController {
public void view(HttpServletRequest request, HttpServletResponse response) { public void view(HttpServletRequest request, HttpServletResponse response) {
// ISO-8859-1 ==> UTF-8 进行编码转换 // ISO-8859-1 ==> UTF-8 进行编码转换
String imgPath = extractPathFromPattern(request); String imgPath = extractPathFromPattern(request);
if(oConvertUtils.isEmpty(imgPath) || CommonConstant.STRING_NULL.equals(imgPath)){ if (oConvertUtils.isEmpty(imgPath) || CommonConstant.STRING_NULL.equals(imgPath)) {
return; return;
} }
// 其余处理略 // 其余处理略
InputStream inputStream = null; InputStream inputStream = null;
OutputStream outputStream = null; OutputStream outputStream = null;
try { try {
imgPath = imgPath.replace("..", "").replace("../",""); imgPath = imgPath.replace("..", "").replace("../", "");
if (imgPath.endsWith(SymbolConstant.COMMA)) { if (imgPath.endsWith(SymbolConstant.COMMA)) {
imgPath = imgPath.substring(0, imgPath.length() - 1); imgPath = imgPath.substring(0, imgPath.length() - 1);
} }
@ -227,15 +227,20 @@ public class CommonController {
String filePath = uploadpath + File.separator + imgPath; String filePath = uploadpath + File.separator + imgPath;
File file = new File(filePath); File file = new File(filePath);
if(!file.exists()){ if (!file.exists()) {
response.setStatus(404); response.setStatus(404);
log.error("文件["+imgPath+"]不存在.."); log.error("文件[" + imgPath + "]不存在..");
return; return;
//throw new RuntimeException();
} }
// 获取文件大小并设置Content-Length
long fileLength = file.length();
response.setHeader("Content-Length", String.valueOf(fileLength));
// 设置强制下载不打开 // 设置强制下载不打开
response.setContentType("application/force-download"); response.setContentType("application/force-download");
response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1")); response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"), "iso-8859-1"));
inputStream = new BufferedInputStream(new FileInputStream(filePath)); inputStream = new BufferedInputStream(new FileInputStream(filePath));
outputStream = response.getOutputStream(); outputStream = response.getOutputStream();
byte[] buf = new byte[1024]; byte[] buf = new byte[1024];
@ -264,7 +269,6 @@ public class CommonController {
} }
} }
} }
} }
// /** // /**

View File

@ -1,5 +1,5 @@
server: server:
port: 8080 port: 8082
tomcat: tomcat:
max-swallow-size: -1 max-swallow-size: -1
error: error:
@ -7,7 +7,7 @@ server:
include-stacktrace: ALWAYS include-stacktrace: ALWAYS
include-message: ALWAYS include-message: ALWAYS
servlet: servlet:
context-path: /nursing-unit context-path: /nursing-unit-nacos
compression: compression:
enabled: true enabled: true
min-response-size: 1024 min-response-size: 1024
@ -20,6 +20,12 @@ management:
include: metrics,jeecghttptrace include: metrics,jeecghttptrace
spring: spring:
application:
name: nursing-unit-nacos
cloud:
nacos:
discovery:
service-name: nursing-unit-nacos
# flyway配置 # flyway配置
flyway: flyway:
# 是否启用flyway # 是否启用flyway
@ -163,10 +169,10 @@ spring:
slow-sql-millis: 5000 slow-sql-millis: 5000
datasource: datasource:
master: master:
url: jdbc:mysql://localhost:40521/nursing_unit?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai url: jdbc:mysql://mysql8-prod:3306/nursing_unit?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
# url: jdbc:mysql://localhost:3306/nursing_unit_001?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai # url: jdbc:mysql://localhost:3306/nursing_unit_001?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: root username: fw8864sshdang
password: BLXC@123. password: uGDBkM25I6nZCNM2
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
# 多数据源配置 # 多数据源配置
#multi-datasource1: #multi-datasource1:
@ -176,10 +182,10 @@ spring:
#driver-class-name: com.mysql.cj.jdbc.Driver #driver-class-name: com.mysql.cj.jdbc.Driver
#redis 配置 #redis 配置
redis: redis:
database: 0 database: 1
host: 127.0.0.1 host: redis
port: 6379 port: 6379
password: password: uUgrUus4JAYuwxzo
#mybatis plus 设置 #mybatis plus 设置
mybatis-plus: mybatis-plus:
mapper-locations: classpath*:org/jeecg/**/xml/*Mapper.xml,classpath*:com/nu/**/xml/*Mapper.xml mapper-locations: classpath*:org/jeecg/**/xml/*Mapper.xml,classpath*:com/nu/**/xml/*Mapper.xml
@ -225,9 +231,9 @@ jeecg:
app: http://localhost:8051 app: http://localhost:8051
path: path:
#文件上传根目录 设置 #文件上传根目录 设置
upload: /opt/upFiles upload: /opt/nu/upFiles
#webapp文件路径 #webapp文件路径
webapp: /opt/webapp webapp: /opt/nu/webapp
shiro: shiro:
excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/bigscreen/category/**,/bigscreen/visual/**,/bigscreen/map/**,/jmreport/bigscreen2/** excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/bigscreen/category/**,/bigscreen/visual/**,/bigscreen/map/**,/jmreport/bigscreen2/**
#阿里云oss存储和大鱼短信秘钥配置 #阿里云oss存储和大鱼短信秘钥配置

View File

@ -0,0 +1,16 @@
spring:
cloud:
nacos:
discovery:
server-addr: ${config.server-addr}
namespace: ${config.namespace}
group: ${config.group}
username: ${config.username}
password: ${config.password}
config:
server-addr: ${config.server-addr}
namespace: ${config.namespace}
group: ${config.group}
file-extension: yaml
username: ${config.username}
password: ${config.password}

21
pom.xml
View File

@ -150,6 +150,17 @@
<artifactId>commonmark</artifactId> <artifactId>commonmark</artifactId>
<version>${commonmark.version}</version> <version>${commonmark.version}</version>
</dependency> </dependency>
<!-- Nacos 服务发现 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
</dependency>
<!-- Nacos 配置中心 -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
</dependencies> </dependencies>
<dependencyManagement> <dependencyManagement>
@ -465,7 +476,7 @@
<id>dev</id> <id>dev</id>
<activation> <activation>
<!--默认激活配置--> <!--默认激活配置-->
<activeByDefault>true</activeByDefault> <activeByDefault>false</activeByDefault>
</activation> </activation>
<properties> <properties>
<!--当前环境--> <!--当前环境-->
@ -517,21 +528,21 @@
<id>uat</id> <id>uat</id>
<activation> <activation>
<!--默认激活配置--> <!--默认激活配置-->
<activeByDefault>false</activeByDefault> <activeByDefault>true</activeByDefault>
</activation> </activation>
<properties> <properties>
<!--当前环境--> <!--当前环境-->
<profile.name>uat</profile.name> <profile.name>uat</profile.name>
<!--Nacos服务地址--> <!--Nacos服务地址-->
<config.server-addr>jeecg-boot-nacos:8848</config.server-addr> <config.server-addr>121.36.88.64</config.server-addr>
<!--Nacos配置中心命名空间,用于支持多环境.这里必须使用ID不能使用名称,默认为空--> <!--Nacos配置中心命名空间,用于支持多环境.这里必须使用ID不能使用名称,默认为空-->
<config.namespace></config.namespace> <config.namespace></config.namespace>
<!--Nacos配置分组名称--> <!--Nacos配置分组名称-->
<config.group>DEFAULT_GROUP</config.group> <config.group>DEFAULT_GROUP</config.group>
<!--Nacos用户名--> <!--Nacos用户名-->
<config.username></config.username> <config.username>fw8864nasadn</config.username>
<!--Nacos密码--> <!--Nacos密码-->
<config.password></config.password> <config.password>JINisgIngV82G2</config.password>
</properties> </properties>
</profile> </profile>
<!-- 生产 --> <!-- 生产 -->