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

View File

@ -1,5 +1,5 @@
server:
port: 8080
port: 8082
tomcat:
max-swallow-size: -1
error:
@ -7,7 +7,7 @@ server:
include-stacktrace: ALWAYS
include-message: ALWAYS
servlet:
context-path: /nursing-unit
context-path: /nursing-unit-nacos
compression:
enabled: true
min-response-size: 1024
@ -20,6 +20,12 @@ management:
include: metrics,jeecghttptrace
spring:
application:
name: nursing-unit-nacos
cloud:
nacos:
discovery:
service-name: nursing-unit-nacos
# flyway配置
flyway:
# 是否启用flyway
@ -163,10 +169,10 @@ spring:
slow-sql-millis: 5000
datasource:
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
username: root
password: BLXC@123.
username: fw8864sshdang
password: uGDBkM25I6nZCNM2
driver-class-name: com.mysql.cj.jdbc.Driver
# 多数据源配置
#multi-datasource1:
@ -176,10 +182,10 @@ spring:
#driver-class-name: com.mysql.cj.jdbc.Driver
#redis 配置
redis:
database: 0
host: 127.0.0.1
database: 1
host: redis
port: 6379
password:
password: uUgrUus4JAYuwxzo
#mybatis plus 设置
mybatis-plus:
mapper-locations: classpath*:org/jeecg/**/xml/*Mapper.xml,classpath*:com/nu/**/xml/*Mapper.xml
@ -225,9 +231,9 @@ jeecg:
app: http://localhost:8051
path:
#文件上传根目录 设置
upload: /opt/upFiles
upload: /opt/nu/upFiles
#webapp文件路径
webapp: /opt/webapp
webapp: /opt/nu/webapp
shiro:
excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/bigscreen/category/**,/bigscreen/visual/**,/bigscreen/map/**,/jmreport/bigscreen2/**
#阿里云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>
<version>${commonmark.version}</version>
</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>
<dependencyManagement>
@ -465,7 +476,7 @@
<id>dev</id>
<activation>
<!--默认激活配置-->
<activeByDefault>true</activeByDefault>
<activeByDefault>false</activeByDefault>
</activation>
<properties>
<!--当前环境-->
@ -517,21 +528,21 @@
<id>uat</id>
<activation>
<!--默认激活配置-->
<activeByDefault>false</activeByDefault>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<!--当前环境-->
<profile.name>uat</profile.name>
<!--Nacos服务地址-->
<config.server-addr>jeecg-boot-nacos:8848</config.server-addr>
<config.server-addr>121.36.88.64</config.server-addr>
<!--Nacos配置中心命名空间,用于支持多环境.这里必须使用ID不能使用名称,默认为空-->
<config.namespace></config.namespace>
<!--Nacos配置分组名称-->
<config.group>DEFAULT_GROUP</config.group>
<!--Nacos用户名-->
<config.username></config.username>
<config.username>fw8864nasadn</config.username>
<!--Nacos密码-->
<config.password></config.password>
<config.password>JINisgIngV82G2</config.password>
</properties>
</profile>
<!-- 生产 -->