springboot 文件的上传、下载与在线预览

本文详述了在SpringBoot中如何实现文件的上传、下载以及使用pdf.js和openoffice进行在线预览。针对不同文件类型,文章提供了具体处理方法,并分享了在实际操作中遇到的问题及解决方案,包括openoffice的配置与使用,以及解决IE浏览器预览问题的策略。同时,给出了参考链接和代码资源。
摘要由CSDN通过智能技术生成

文件的上传和下载都比较简单,在线预览比较复杂,针对不同类型的文件可能要进行不同的处理。

本文使用了 pdf.js 和 openoffice 两种方法实现文件的预览


pom.xml
上传和下载都不需要添加什么依赖,该文件中除了springboot本身的依赖就是在线预览需要的依赖

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-thymeleaf</artifactId>
		</dependency>
		
		<!--jodconverter 核心包 -->
		<!-- https://mvnrepository.com/artifact/org.jodconverter/jodconverter-core -->
		<dependency>
			<groupId>org.jodconverter</groupId>
			<artifactId>jodconverter-core</artifactId>
			<version>4.3.0</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/org.artofsolving.jodconverter/jodconverter-core -->
		<!-- 
		<dependency>
		    <groupId>org.artofsolving.jodconverter</groupId>
		    <artifactId>jodconverter-core</artifactId>
		    <version>3.0-beta-4</version>
		</dependency>
		 -->

		<!--springboot支持包,里面包括了自动配置类 -->
		<!-- https://mvnrepository.com/artifact/org.jodconverter/jodconverter-spring-boot-starter -->
		<dependency>
		    <groupId>org.jodconverter</groupId>
		    <artifactId>jodconverter-spring-boot-starter</artifactId>
		    <version>4.3.0</version>
		</dependency>

		
		<!--jodconverter 本地支持包 -->
		<!-- https://mvnrepository.com/artifact/org.jodconverter/jodconverter-local -->
		<dependency>
			<groupId>org.jodconverter</groupId>
			<artifactId>jodconverter-local</artifactId>
			<version>4.3.0</version>
		</dependency>

		<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
		<dependency>
			<groupId>commons-io</groupId>
			<artifactId>commons-io</artifactId>
			<version>2.6</version>
		</dependency>
	</dependencies>

fileTest.html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<h3>文件上传</h3>
	<form action
  • 3
    点赞
  • 46
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值