Um eine Datei mit jQuery AJAX an ein Spring Boot Backend zu übergeben, kannst du die folgenden Schritte befolgen: 1. **HTML-Formular erstellen:** Erstelle ein HTML-Formular mit einem Datei-Upload-Feld. ```html <form id="fileUploadForm" enctype="multipart/form-data"> <input type="file" id="file" name="file" /> <button type="button" onclick="uploadFile()">Upload</button> </form> ``` 2. **jQuery AJAX-Funktion:** Implementiere die jQuery AJAX-Funktion, um die Datei an den Server zu senden. ```javascript function uploadFile() { var formData = new FormData(); formData.append('file', $('#file')[0].files[0]); $.ajax({ url: '/upload', // URL des Endpunkts im Spring Boot Backend type: 'POST', data: formData, processData: false, contentType: false, success: function(response) { console.log('File uploaded successfully'); }, error: function(jqXHR, textStatus, errorThrown) { console.log('File upload failed'); } }); } ``` 3. **Spring Boot Controller:** Erstelle einen Controller in deinem Spring Boot Backend, um die Datei zu empfangen. ```java import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @RestController public class FileUploadController { @PostMapping("/upload") public String handleFileUpload(@RequestParam("file") MultipartFile file) { if (file.isEmpty()) { return "File is empty"; } // Hier kannst du die Datei speichern oder weiterverarbeiten // z.B. file.transferTo(new File("/path/to/save/" + file.getOriginalFilename())); return "File uploaded successfully: " + file.getOriginalFilename(); } } ``` Mit diesen Schritten kannst du eine Datei von einem HTML-Formular über jQuery AJAX an ein Spring Boot Backend übergeben.