小编use*_*935的帖子

必需的MultipartFile参数'file'不存在

我正在使用Spring Boot来测试上传功能,并且"不存在'必需的MultipartFile参数'文件'错误".以下是1)JSP,2)控制器3)配置类4)嵌入式tomcat日志.

  1. JSP页面

    ----------------------------------------------------------------------------
    <!DOCTYPE html>
    
    <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    
    <html lang="en">
    
    <body>
        <br>Message: ${message}
        <h2>List Of Objects</h2>
    
        <br>
        <h2>Upload New File to this Bucket</h2>
        <form action="uploadObject" method="post" enctype="multipart/form-data">
            <table width="60%" border="1" cellspacing="0">
                <tr>
                    <td width="35%"><strong>File to upload</strong></td>
                    <td width="65%"><input type="file" name="file" /></td>
                </tr>
                <tr>
                    <td>&nbsp;</td>
                    <td><input type="submit" name="submit" value="Add" /></td>
                </tr>
            </table>
        </form>
    </body>
    </html>
    
    Run Code Online (Sandbox Code Playgroud)

2.控制器:

@RequestMapping(value = "/uploadObject", method = RequestMethod.POST)
    @Override
    public String upload(@RequestParam("file") MultipartFile file,
            @RequestParam("bucketName") String bucketName,
            Map<String, Object> model) { …
Run Code Online (Sandbox Code Playgroud)

file-upload spring-boot

6
推荐指数
2
解决办法
1万
查看次数

Spring boot:不支持请求方法“PUT”

Request method 'PUT' not supported我在使用Restful API 上的PUT方法上传文件时遇到错误。

以下是上传到此票证的信息。

  1. 客户端日志
  2. 休息控制器
  3. Spring Boot 应用程序配置
  4. Tomcat日志
  5. POM.xml

1. 客户端日志

$ curl -X PUT -T  "/cygdrive/c/a/documents/test.pptx" http://localhost:8080/piranha-storage-service/buckets/gnaval.bucket1/test.pptx
<html><head><title>Apache Tomcat/7.0.52 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 405 - Request method 'PUT' not supported</h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u>Request method 'PUT' not supported</u></p><p><b>description</b> <u>The specified HTTP method is not allowed for the requested …
Run Code Online (Sandbox Code Playgroud)

rest put spring-boot

3
推荐指数
1
解决办法
3万
查看次数

标签 统计

spring-boot ×2

file-upload ×1

put ×1

rest ×1