Загрузка многочастного файла Spring MVC с использованием ajax.Я использую Spring Security, поэтому я также добавил токен CSRF.Я получаю следующую ошибку: org.springframework.web.servlet.PageNotFound handleHttpRequestMethodNotSupported WARNING: Request method 'POST' not supported
Форма ввода jsp:
<form id="fileUploadForm" enctype="multipart/form-data" method="POST">
<input name="id" type="hidden" id="id" value="55" />
<input type="file" class="custom-file-input" id="photo" name="photo" aria-
describedby="photoAddon">
<input type="file" class="custom-file-input" id="sign" name="sign" aria-
describedby="signAddon">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" />
<button type="button" class="btn btn-success"
onclick="profWrapper.uploadPhotoSign()">Upload</button>
</form>
Код Ajax:
uploadPhotoSign : function() {
event.preventDefault();
// Get form
var form = $('#fileUploadForm')[0];
// Create an FormData object
var formData = new FormData(form);
$.ajax({
type: "POST",
enctype: 'multipart/form-data',
url: "uploadPhotoSign",
data: formData,
processData: false, // prevent jQuery form transforming the data into a query string
contentType: false,
cache: false,
timeout: 600000,
succecc: function(data) {
console.log(data);
},
error: function(e) {
console.log(e.responseText);
}
});
}
Контроллер:
@PostMapping("uploadPhotoSign")
public ResponseEntity<String> savePhotoSign(HttpServletRequest request,
@RequestParam MultipartFile photo,
@RequestParam MultipartFile sign,
@RequestParam("id") int id){