在 Spring MVC 中上传文件时,我发现很多文章建议您将其存储到文件系统文件夹中,而不是项目内部的文件夹中。
但我的网络应用程序使用来自webapp文件夹内的文件夹的文件呈现 HTML(视图)页面。
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com // Where my application's is.
│ │ ├── resources
│ │ │ ├── META-INF
│ │ │ ├── log4j.xml
│ │ │ ├── maildata.properties
│ │ │ └── persistence-mysql.properties
│ │ └── webapp
│ │ ├── WEB-INF
│ │ │ ├── classes
│ │ │ ├── spring
│ │ │ ├── templates // Where my view pages are. Thymeleaf template used.
│ │ │ │ ├── login.html
│ │ │ │ ├── index.html
│ │ │ │ └── ...html and More...
│ │ │ └── web.xml
│ │ └── resources // --> This is location that my app use for rendering.
│ │ ├── css
│ │ ├── fonts
│ │ ├── images
│ │ ├── js
│ │ └── vendors
│ └── test
│ ├── java
│ │ └── com
│ └── resources
│ └── log4j.xml
└── target
在我的视图部分,我使用资源文件夹中的文件来呈现 HTML 页面。
.
.
<link rel="stylesheet" th:href="@{'/resources/css/style.css'}" type="text/css">
.
.
.outbox {
background:
url([[@{/resources/images/header.jpg}]]) #000
55% 0 no-repeat;
background-size: 140% auto;
margin-top: -68px;
width: 100%;
padding-top: 42.25%;
position: relative;
display: block;
z-index: -1;
}
.
.
.
我想制作将文件上传到资源文件夹并使用它来呈现 HTML 页面的功能。
这是一个坏主意吗?你能解释一下为什么吗?
如果是这样,我可以为我的任务采取的最佳方法是什么?(上传文件的最佳位置)
人到中年有点甜
相关分类