From d04728d8fa2e4bee55441ffdc931c80d75bfb163 Mon Sep 17 00:00:00 2001 From: zzl <961867786@qq.com> Date: Thu, 26 Jun 2025 11:25:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=A1=86=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/ruoyi/common/utils/pdf/PdfUtils.java | 5 ++++- ruoyi-generator/src/main/resources/vm/vue/index.vue.vm | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/pdf/PdfUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/pdf/PdfUtils.java index a70d983..db00422 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/pdf/PdfUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/pdf/PdfUtils.java @@ -12,6 +12,7 @@ import com.ruoyi.common.core.domain.pdf.PdfProperty; import com.ruoyi.common.core.domain.pdf.ShoulderItem; import com.ruoyi.common.utils.StringUtils; import lombok.extern.slf4j.Slf4j; +import org.springframework.http.MediaType; import javax.servlet.http.HttpServletResponse; import java.io.ByteArrayOutputStream; @@ -94,9 +95,11 @@ public class PdfUtils { // 5. 关闭文档 document.close(); // 6. 将PDF输出到浏览器 - response.setContentType("application/pdf"); + response.setContentType(MediaType.APPLICATION_PDF_VALUE); response.setCharacterEncoding("utf-8"); response.setContentLength(baos.size()); + response.setHeader("Pragma", "public"); + response.setHeader("Cache-Control", "public, must-revalidate"); response.setHeader("Content-Disposition", "inline; filename=example.pdf"); response.getOutputStream().write(baos.toByteArray()); response.getOutputStream().flush(); diff --git a/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm index 5f140f0..aa62209 100644 --- a/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm +++ b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm @@ -105,9 +105,9 @@ - - - + + + #foreach($column in $columns) #set($javaField=$column.javaField) #set($parentheseIndex=$column.columnComment.indexOf("("))