未分类
2021-03-29 15:11:42
1822677238@qq.com
Linux运行SpringBoot项目出现404解决方案
修改项目的 pom.xml文件,依赖请根据自身项目情况进行摘选
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.54</version>
</dependency>
<!--druid连接池--> (更多…)
未分类
2021-03-29 15:08:00
1822677238@qq.com
控制层:
@Controller
@RequestMapping("/")
public class UploadController {
@RequestMapping("/")
public String index(){return "upload";}
// 得到一个新的文件路径
public String realPath(String path){
SimpleDateFormat y=new SimpleDateFormat("yyyy");
SimpleDateFormat m=new SimpleDateFormat("MM");
SimpleDateFormat d=new SimpleDateFormat("dd");
Date date=new Date(System.currentTimeMillis());
String year = y.format(date);
String month = m.format(date);
String day = d.format(date);
String realPath=path+ File.separator+year+File.separator+month+File.separator+day;
File file=new File(realPath);
if(!file.exists()) file.mkdirs();
return realPath;
} (更多…)


