Spring ThymileAF无法将多部分文件转换为字节

Spring ThymileAF无法将多部分文件转换为字节,spring,thymeleaf,multipartform-data,Spring,Thymeleaf,Multipartform Data,在将图像插入数据库时,我遇到了将多部分文件转换为字节[]的问题 当我使用这种输入类型时,插入过程不会出错 <input type="file" name="file" class="form-control mb-4 col-4" placeholder="Image"> <input type="file" name="file" th:field="*{image}" class="form-

在将图像插入数据库时,我遇到了将多部分文件转换为字节[]的问题

当我使用这种输入类型时,插入过程不会出错

<input type="file" name="file"
                    class="form-control mb-4 col-4" placeholder="Image">
<input type="file" name="file" th:field="*{image}"
                    class="form-control mb-4 col-4" placeholder="Image">
在我知道th:字段后,多部分文件的定义如下控制器部分所示

@RequestParam("image") MultipartFile file <-> th:field="*{image}"
@RequestParam(“image”)多部分文件th:field=“*{image}”
如何修复此转换过程?

尝试以下操作:

public String imageMultipart(@RequestParam("file") MultipartFile multipartFile) throws IOException {
        byte[] bytes = multipartFile.getBytes();
        return "something";
    }
@RequestParam(“文件”)无法与来自th:field=“*{image}”的值匹配。它抛出转换错误。如果不使用th:field=“*{image}”,则不会出现任何打字错误。
public String imageMultipart(@RequestParam("file") MultipartFile multipartFile) throws IOException {
        byte[] bytes = multipartFile.getBytes();
        return "something";
    }