Commit d74c0e7b by fengshuonan

更新pdf预览

parent 342a1adb
...@@ -19,15 +19,12 @@ import cn.stylefeng.roses.core.base.controller.BaseController; ...@@ -19,15 +19,12 @@ import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.util.ToolUtil; import cn.stylefeng.roses.core.util.ToolUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import java.io.IOException;
/** /**
* pdf预览 * pdf预览
* *
...@@ -53,16 +50,15 @@ public class PdfPreviewController extends BaseController { ...@@ -53,16 +50,15 @@ public class PdfPreviewController extends BaseController {
*/ */
@GetMapping(value = "/loadPdfFile", produces = "application/pdf") @GetMapping(value = "/loadPdfFile", produces = "application/pdf")
@ResponseBody @ResponseBody
public FileSystemResource loadPdfFile(@RequestParam(value = "file", required = false) String file) { public ClassPathResource loadPdfFile(@RequestParam(value = "file", required = false) String file) {
if (ToolUtil.isEmpty(file)) { if (ToolUtil.isEmpty(file)) {
file = "demo.pdf"; file = "demo.pdf";
} }
try { try {
ClassPathResource classPathResource = new ClassPathResource("assets/expand/pdf/demo/" + file); return new ClassPathResource("assets/expand/pdf/demo/" + file);
return new FileSystemResource(classPathResource.getFile().getAbsolutePath()); } catch (Exception e) {
} catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment