Q:

Spring MVC, error code 405, method not allowed

I'm getting this in the console when I'm trying to update data in my database, using spring mvc and ajax from my jsp. 
http://localhost:8080/my_project/activerutilisateur/user 405 (Méthode Non Autorisée)

See my code below:
DAO
public Utilisateur updateUtilisateur(Utilisateur utilisateur) {
    sessionFactory.getCurrentSession().update(utilisateur);
    return utilisateur;
}

Controller
@RequestMapping(value="/activerutilisateur/{username}", method=RequestMethod. PUT, produces = MediaType. APPLICATION_JSON_VALUE, consumes = MediaType. APPLICATION_JSON_VALUE)
@ResponseBody
public Utilisateur activerUtilisateur(@PathVariable String username, @RequestBody Utilisateur utilisateur) {
    utilisateur = service.getUtilisateurById(username);
    utilisateur.setEnable(true);
    return service.updateUtilisateur(utilisateur);
}

Ajax request
<script>
      function activerUtilisateur(username) {

          var user = {"username" : username}

          $.ajax({
              contentType: 'application/json',
              type: 'POST',
              url: 'activerutilisateur/',
              data : JSON.stringify(user),

              error: function(xhr,error,textStatus){
                  console.log(textStatus);
              },

              complete: function(data) {
                  console.log(data);
                  console.log('complete done');
              },

              success: function(data) {
                  alert('success done');
              }
          });
      }   
    </script>

It's the only method which doesn't work in the project
Someone could please help me to find what I did wrong? 
Thanks

A:

I finally found what's wrong here : 
https://matthewbusche.com/blog2/2016/08/06/using-csrf-with-spring-security-and-ajax-calls/
It's due to csrf

