Spring MVC - Handling HTTP PUT Request

[Last Updated: Feb 23, 2018]

This tutorial shows how to handle HTTP PUT request in Spring MVC

According to Spring reference document:

The spring-web module provides HttpPutFormContentFilter that intercepts HTTP PUT and PATCH requests with content type application/x-www-form-urlencoded, reads the form data from the body of the request, and wraps the ServletRequest in order to make the form data available through the ServletRequest.getParameter*() family of methods.

In the following example, we will submit the PUT request from JQuery and instead of using ServletRequest we will use @RequestBody MultiValueMap to access the form parameter.


The controller

public class ArticleController {

  private ArticleService articleService;

  public String getArticleForm() {
      return "article-form";

  public String createNewArticle(@RequestBody MultiValueMap<String, String> formParams) {
      long id = Long.parseLong(formParams.getFirst("id"));
      String content = formParams.getFirst("content");
      Article article = new Article(id, content);
      return "Article created.";

  public String getArticle(@PathVariable("id") long id, Model model) {
      Article article = articleService.getArticleById(id);
      model.addAttribute("article", article);
      return "article-page";
public class Article {
  private long id;
  private String content;

  public Article(long id, String content) { = id;
      this.content = content;



<h3>Article Form</h3>
<form id="article-form">
         id: <input type="text" name="id">
    content: <input type="text" name="content">
                  <input type="submit" value="Submit">
<div id="result"></div>

            var form = $(this);
            var id = form.find('input[name="id"]').val();
            var url = 'http://localhost:8080/articles/'+id;
            var content = form.find('input[name="content"]').val();

                type : 'PUT',
                url : url,
                contentType: 'application/x-www-form-urlencoded',
                data : "id="+id+"&content="+content,
                success : function(data, status, xhr){
                   " link: <a href='"+url+"'>"+url+"</a>");
                error: function(xhr, status, error){




Java Config

public class MyWebConfig implements WebMvcConfigurer {

  public void configureViewResolvers(ViewResolverRegistry registry) {
      registry.jsp("/WEB-INF/views/", ".jsp");


To try examples, run embedded tomcat (configured in pom.xml of example project below):

mvn tomcat7:run-war

Accessing http://localhost:8080/articles and filling up the form:

On submitting the form:

Clicking on the hyper link of the article:

See also Servlet - doPut() Example.

Example Project

Dependencies and Technologies Used:

  • spring-webmvc 5.0.3.RELEASE: Spring Web MVC.
  • javax.servlet-api 3.0.1 Java Servlet API
  • jstl 1.2 javax.servlet:jstl
  • JDK 1.8
  • Maven 3.3.9

Spring Http Put Request Method Example Select All Download
  • spring-put-example
    • src
      • main
        • java
          • com
            • logicbig
              • example
          • webapp
            • WEB-INF
              • views

    See Also