title: Send post request with Angular 2 and Spring Boot
body: <p>I use Angular 2 and Spring Boot. From an html form I want to send data to a local mongo db. The form has a Submit Function which should send the data to the PersonController Java file. But the post request does not work. 
  I hope you can help me. Thanks in advance.</p>
  
  <p>onSubmit() Function</p>
  
  <pre><code>    private serverUrl = 'http://localhost:8080/saveUser';
  
  onSubmit() {
  
      let headers = new Headers({'Content-Type': 'application/json'});
      this.http.post(this.serverUrl,
          {firstName: 'name.firstname',lastName: 'name.lastname'},
          {headers:headers})
          .map((res: Response) =&gt; res.json());
  
      this.name = {
          firstname: '',
          lastname: ''
      }
  </code></pre>
  
  <p>HTML Code: </p>
  
  <pre><code> &lt;form (ngSubmit)="onSubmit()" #nameForm="ngForm" &gt;
    &lt;div class="form-group"&gt;
      &lt;label for="Firstname"&gt;Firstname&lt;/label&gt;
      &lt;input type="text" class="form-control" id="firstname"
      required
      [(ngModel)]="name.firstname" name="firstname"&gt;
    &lt;/div&gt;
  
    &lt;div class="form-group"&gt;
      &lt;label for="Lastname"&gt;Lastname&lt;/label&gt;
      &lt;input type="text" class="form-control" id="lastname"
      [(ngModel)]="name.lastname" name="lastname"&gt;
    &lt;/div&gt;
    &lt;button type="submit" class="btn btn-default" &gt;Submit&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>PersonController</p>
  
  <pre><code>@Autowired
  PersonRepository personRepository;
  
  @RequestMapping("/saveUser")
  public String personForm(){
      Person person1 = new Person("Hans", "Meiser");
      personRepository.save(person1);
      return "saved";
  }
  </code></pre>