@GetMapping("/view")
@ApiOperation("查看预览文件")
@CrossOrigin
// 前端传入文件名查看文件;
public void viewFile(String fullFileName, HttpServletResponse response, HttpServletRequest request) throws Exception {
// 获取同一个网络可以访问的本机IP地址;
String hostAddress = InetAddress.getLocalHost().getHostAddress();
log.info("本机IP地址:{}" , hostAddress);
// 解决 response.sendRedirect 中文乱码;
response.sendRedirect(new String(("http://"+hostAddress+":8012/demo/"
+ fullFileName).getBytes(StandardCharsets.UTF_8), StandardCharsets.ISO_8859_1));
log.info("重定向的url:{}", "http://"+hostAddress+":8012/demo/" + fullFileName);
}
kkfileView预览文件, 解决URL中文乱码;
最新推荐文章于 2024-05-10 14:18:12 发布