Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Controller
- @Log4j2
- public class UploadController {
- @Autowired
- private UploadService uploadService;
- @RequestMapping("/uploadForm.html")
- public String uploadForm()
- {
- return "uploadForm";
- }
- @PostMapping("/uploadForm.html")
- public String handleFileUpload(@RequestParam("file") MultipartFile file, Model model) {
- try {
- uploadService.store(file);
- model.addAttribute("message", "You successfully uploaded " + file.getOriginalFilename() + "!");
- } catch (Exception e) {
- model.addAttribute("message", "FAIL to upload " + file.getOriginalFilename() + "!");
- }
- return "uploadForm";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement