title: How to send form data to controller
body: <p>I have a simple J2ee application.
  I want to create a simple form of registration, then send the data at controller to storage the data in mysql database.
  So I have this jsp page:</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
          &lt;meta charset="utf-8"&gt;
          &lt;title&gt;Registrazione&lt;/title&gt;
      &lt;/head&gt;
  &lt;body&gt;
  
      &lt;h2&gt;${msg}&lt;/h2&gt;
      &lt;form action="/sendDati" method="POST"&gt;
          &lt;label&gt;Nome &lt;span class="color-red"&gt;*&lt;/span&gt;&lt;/label&gt;
          &lt;input type="text" class="form-control margin-bottom-20" name="nome" required&gt;&lt;/input&gt;      
  
          &lt;label&gt;Email &lt;span class="color-red"&gt;*&lt;/span&gt;&lt;/label&gt;
          &lt;input type="email" class="form-control margin-bottom-20" name="email" required&gt;&lt;/input&gt;
  
          &lt;label&gt;Password &lt;span class="color-red"&gt;*&lt;/span&gt;&lt;/label&gt;
          &lt;input type="password" class="form-control margin-bottom-20" name="password" required&gt;&lt;/input&gt;                          
  
          &lt;label&gt;Conferma Password &lt;span class="color-red"&gt;*&lt;/span&gt;&lt;/label&gt;
          &lt;input type="password" class="form-control margin-bottom-20" name="password1" required&gt;&lt;/input&gt;
          &lt;button type="submit" class="btn btn-primary"&gt;REGISTRATI&lt;/button&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and this is the controller:</p>
  
  <pre><code>package com.springmvcapp.controller;
  
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestParam;
  import org.springframework.web.servlet.ModelAndView;
  
  @Controller
  public class RegistrazioneController {
  
      @RequestMapping("/registrazione")
      public ModelAndView helloWorld(){
  
          ModelAndView model = new ModelAndView("registrazione");
          model.addObject("msg", "hello world");
          return model;
      }
  
      @RequestMapping(value = "/sendDati")
      public String getDataFromForum(@RequestParam String nome){
          System.out.println("pippo");
          return nome;
      }
  }
  </code></pre>
  
  <p>But when I try to click on Registrazione button I received this error</p>
  
  <pre><code>HTTP Status 404 - /sendDati
  </code></pre>
  
  <p>How can I fixed this error?</p>
  
  <p>EDIT:</p>
  
  <p>springmvcapp-servlet.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:p="http://www.springframework.org/schema/p"
      xmlns:context="http://www.springframework.org/schema/context"
      xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  http://www.springframework.org/schema/context
  http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt;
  
      &lt;context:component-scan base-package="com.springmvcapp.controller" /&gt;
      &lt;bean id="viewResolver"
          class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
          &lt;property name="viewClass"
              value="org.springframework.web.servlet.view.JstlView" /&gt;
          &lt;property name="prefix" value="/WEB-INF/jsp/" /&gt;
          &lt;property name="suffix" value=".jsp" /&gt;
      &lt;/bean&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" 
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  id="WebApp_ID" version="2.5"&gt;
    &lt;display-name&gt;SpringMVCApp&lt;/display-name&gt;
    &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;index.jsp&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
    &lt;servlet&gt;
      &lt;servlet-name&gt;springmvcapp&lt;/servlet-name&gt;
      &lt;servlet-class&gt;
              org.springframework.web.servlet.DispatcherServlet
          &lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;springmvcapp&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.html&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>EDIT 2
  I have change this. When I try to open my registrazione.jsp page I use this method:</p>
  
  <pre><code>&lt;form action="RegistrazioneController/registrazione.html"&gt;
                              &lt;button class="btn btn-primary btn-lg" data-toggle="modal" onclick="submit"&gt;
                                 Registrazione
                              &lt;/button&gt;
                          &lt;/form&gt;
  </code></pre>
  
  <p>My Jsp form is this:</p>
  
  <pre><code>&lt;form action="RegistrazioneController/sendDati" method="POST"/&gt;
  </code></pre>
  
  <p>My RegistrazioneController class is this:</p>
  
  <pre><code>@Controller
  @RequestMapping("/RegistrazioneController")
  public class RegistrazioneController {
  
      @RequestMapping("/registrazione")
      public ModelAndView helloWorld(){
  
          ModelAndView model = new ModelAndView("registrazione");
          model.addObject("msg", "hello world");
          return model;
      }
  
      @RequestMapping(value = "/sendDati")
      public String getDataFromForum(@RequestParam String nome){
          System.out.println("pippo");
          return nome;
      }
  }
  </code></pre>