[英]Cannot resolve method 'resolve' for URI
我正在制作一个Spring Boot应用程序来提供图像。 我的createFile
方法尝试从POST请求获取URI,但无法解析文件名。
下面,我正在尝试发出POST请求以提供图片。 我在URI下有关于resolve
方法的错误。 我尝试了3种进口,如下所述:
//1
import java.net.URI;
//2
import com.sun.org.apache.xml.internal.utils.URI;
//3
import com.sun.org.apache.xerces.internal.util.URI;
这些似乎都不起作用。
以下是我要提供的POST请求,以提供图片。
private static final String BASE_PATH = "/images";
//for Curl. Development and testing
@RequestMapping(method = RequestMethod.POST,value = BASE_PATH )
@ResponseBody
public ResponseEntity<?> createFile(@RequestParam("file") MultipartFile file, HttpServletRequest servletRequest) {
try {
imageService.createImage(file);
final URI locationUri = new Uri(servletRequest.getRequestURL().toString() + "/")
.resolve(file.getOriginalFilename() + "/raw");//error here on resolve
return ResponseEntity.created(locationUri)
.body("Succesfull" + file.getOriginalFilename());
} catch (IOException e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body("Could not find " + file.getOriginalFilename() + "=>" + e.getMessage());
}
}
嗨,请将Uri更改为URI,如下所示
final URI locationUri = new URI(servletRequest.getRequestURL().toString() + "/")
.resolve(file.getOriginalFilename() + "/raw");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.