Я пытаюсь загрузить файл с помощью Spring boot, но не могу избавиться от этой ошибки "Страница ошибок Whitelabel В этом приложении нет явного сопоставления для / error, поэтому вы видите это как запасной вариант.
Чт, 07 ноября 17:37:29 IST 2019 Произошла непредвиденная ошибка (тип = Не найдено, статус = 404). Сообщение недоступно. "
Контроллер:
package rest;
import service.Document;
import service.DocumentService;
import service.ResponseMetadata;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
@Controller
@RequestMapping(value = "/doc")
public class DocumentController
{
private static final Logger LOG = Logger.getLogger(DocumentController.class);
@Autowired
DocumentService documentService;
@RequestMapping(value = "/upload", method = RequestMethod.POST)
public @ResponseBody ResponseMetadata handleFileUpload(@RequestParam(value="file") MultipartFile file) throws IOException
{
return documentService.save(file);
}
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public HttpEntity<byte[]> getDocument(@PathVariable Long id)
{
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.IMAGE_JPEG);
return new ResponseEntity<byte[]>(documentService.getDocumentFile(id), httpHeaders, HttpStatus.OK);
}
@RequestMapping(method = RequestMethod.GET)
public @ResponseBody List<Document> getDocument()
{
return documentService.findAll();
}
}