title: How to write a put method with @putmapping
body: <p>I am learning about spring rest api and wrote a following method to save the data into the database.</p>
  
  <pre><code>@GetMapping(path="/add") // Map ONLY GET Requests
  public @ResponseBody String addNewUser (@RequestParam String name
          , @RequestParam String email) {
      // @ResponseBody means the returned String is the response, not a view name
      // @RequestParam means it is a parameter from the GET or POST request
  
      User n = new User();
      n.setName(name);
      n.setEmail(email);
      userRepository.save(n);
      return "Saved";
  }
  </code></pre>
  
  <p>now i want to write the put query which can take user id and then update the name or email. Also, I need to check that username and email should not be null and also email is in valid format.</p>
  
  <p>How can i construct my method using @putmapping to perform my task. </p>