0

I want to upload .txt file, and process in my controller. Here is my .jsp file with my form:

 <form id="uploadForm" action="contact/importContacts" method="POST" enctype="multipart/form-data"> <input type="file" name="file" /> <button id="upload" class="pull-right btn btn-raised btn-primary" type="submit">Upload</button> </form> 

And this is the controller:

@RestController @RequestMapping("/contact") public class ContactController { @RequestMapping(value = "/importContacts") @ResponseBody public String importContacts(@RequestParam("file") MultipartFile file) { if(file != null) { return "OK"; } else { return "NULL"; } } } 

The page is going on /myPage/contact/importContacts, but not in contoller. I put breakpoint on controller, but the app don't stop there. Any solution?

Btw I followed this tut

1 Answer 1

1

You have to explicitly add the RequestMethod

@RequestMapping(method = RequestMethod.POST, value = "/importContacts")

Sign up to request clarification or add additional context in comments.

2 Comments

Noting happens again. Also if I delete importContacts, the app still go to /myPage/contact/importContacts....
Then maybe provide more code. E.g. Application class, configuration files etc.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.