我正在使用Spring Boot来测试上传功能,并且"不存在'必需的MultipartFile参数'文件'错误".以下是1)JSP,2)控制器3)配置类4)嵌入式tomcat日志.
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> </td>
<td><input type="submit" name="submit" value="Add" /></td>
</tr>
</table>
</form>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)@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) Request method 'PUT' not supported我在使用Restful API 上的PUT方法上传文件时遇到错误。
以下是上传到此票证的信息。
$ 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)