I am using spring mvc and I have created a jsp page.
redmn.jsp
<form id="forma" name="forma" action="something" method="post" enctype="multipart/form-data" >
//some fields
<input type="submit" value="Valider" />
</form>
Then I have created one controller to handle my request:
@Controller
public class SecondController{
@RequestMapping(value="/something", method= RequestMethod.POST)
public String addRes( HttpServletRequest req,
BindingResult result,
ModelMap model,
@RequestParam("file") MultipartFile file){
// some treatements
return "redmn"
}
When I am clicking the submit button, I am getting 404 error. Please someone help to resolve this issue.
I think you are missing context path. In order to get correct request path you should append context path.
if you are using spring tag lib
If you are using jstl
and then in your form tag specify action
When you have POST method, in the JSP you should add modelAttribute
In your controller the things should be this way:
Further information about handling you could find in this tutorial http://www.mkyong.com/spring-mvc/spring-mvc-form-handling-example/