Uygulama içinden response döndürdüğüm zaman aşağıdaki hatayı alıyorum. Controller içindeki metoddan debug yaptığım zaman herşey normal görünüyor. İşlemler bittiği zaman dönen response da aşağıdaki hatayı alıyorum.

  • Circular view path [upload]: would dispatch back to the current handler URL [/upload] again. Check your ViewResolver setup! (Hint: This may be the result of an unspecified view, due to default view name generation.)
  • “Error resolving template \”upload\”, template might not exist or might not be accessible by any of the configured Template Resolvers

 

@Controller
public class FileUploadController {
    
   private static final Logger logger = LoggerFactory.getLogger(FileUploadController.class); 
    
   @Autowired
   private FileStorageService fileStorageService;

   @Autowired
   private UploadFileResourceAssembler uploadFileResourceAssembler;
    
      @ApiOperation(notes = "Upload a file", value = "Upload a file", nickname = "post_File")
        @ApiResponses({@ApiResponse(code = 201, message = "Uploaded", response = UploadFileResponse.class),
                @ApiResponse(code = 400, message = "A file upload failed", response = Object.class)})
        @RequestMapping(path = "/upload", method = RequestMethod.POST)
        public Resource<UploadFileResponse> uploadFile(@RequestParam("file") MultipartFile file, @RequestHeader(value = USERNAME) String username) {

            String fileName = fileStorageService.storeFile(file);
            String fileDownloadUri = null;
            try {
                fileDownloadUri = ServletUriComponentsBuilder.fromCurrentContextPath()
                        .path(fileStorageService.loadFileAsResource(fileName).getFile().getAbsolutePath()).path(fileName)
                        .toUriString();
            } catch (IOException e) {
                e.printStackTrace();
            }

            UploadFileResponse createdResource = new UploadFileResponse(fileName, fileDownloadUri, file.getContentType(), file.getSize());

            return uploadFileResourceAssembler.toResource(createdResource);

        }
}