通过网络上传/下载文件夹

问题描述 投票:0回答:1

嘿,我目前正在学习一般开发,并且

我目前有一个带有 thymeleaf 的 springboot 项目,我尝试使用 AdminLTE 模板(简单表)来显示我可以扩展的不同文件夹中的上传文件等。

但这就是我苦苦挣扎的地方,因为目前我只能上传文件、在另一个网站上显示它们以及下载/删除它们。

我试图在互联网上找到一些示例,但找不到任何类似的东西来指导我。

javascript java spring-boot thymeleaf spring-thymeleaf
1个回答
0
投票

这是我的控制器和视图实现之一的一部分,请重新验证,因为它已经有几年了

@Controller
public class FileController {

    @Autowired
    private FileService fileService;

    @GetMapping("/files")
    public String listFiles(Model model) {
        List<File> files = fileService.getAllFiles(); 
        model.addAttribute("files", files);
        return "files"; // put your thymeleaf name
    }

}

和用户界面

<div>
    <table>
        <thead>
            <tr>
                <th>File Name</th>
                <th>Size</th>
            </tr>
        </thead>
        <tbody>
            <tr th:each="file : ${files}">
                <td th:text="${file.name}"></td>
                <td th:text="${file.size}"></td>
            </tr>
        </tbody>
    </table>
</div>
© www.soinside.com 2019 - 2024. All rights reserved.