Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8597589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:56:49+00:00 2026-06-12T00:56:49+00:00

I am using Spring MVC to expose some RESTful web services. One of the

  • 0

I am using Spring MVC to expose some RESTful web services. One of the operations calls for a RESTful PUT operation when a form is submitted.

However, the form is no ordinary form in that it contains a file input along with regular inputs such as text and checkboxes.

I have configured Spring to work with RESTful PUT and DELETE by adding the HiddenHttpMethodFilter in the web.xml. In my forms, i have a hidden _method parameter being sent as well.

All this works fine for DELETE, PUT without file upload, etc. When I try to do a PUT with file upload and form data, it gives me a 405.

HTTP Status 405 - Request method 'POST' not supported

My controller method looks like this:

@RequestMapping(value = "/admin/cars/{carId}", method = PUT, headers = "content-type=multipart/form-data")
public String updateCar(@PathVariable("carId") String carId, CarForm form) {
    // save and return the right view.
}

My HTML form looks like this:

<form action="<c:url value='/admin/cars/${car.id}'/>" method="POST" enctype="multipart/form-data">
    <input type="hidden" name="_method" value="PUT" />
    <input type="text" name="carName" value="${car.name}" />
    <input type="file" name="photo" />
    <input type="submit" />
</form>

Is what I am trying to achieve doable at all using PUT? If so, how to make Spring MVC understand that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T00:56:51+00:00Added an answer on June 12, 2026 at 12:56 am

    Add MultipartFilter to enable file uploads before HiddenHttpMethodFilter in your web.xml (as written in HiddenHttpMethodFilter API docs, see NOTE).

    Also:

    Note: This filter is an alternative to using DispatcherServlet‘s
    MultipartResolver support, for example for web applications with
    custom web views which do not use Spring’s web MVC, or for custom
    filters applied before a Spring MVC DispatcherServlet (e.g.
    HiddenHttpMethodFilter)
    . In any case, this filter should not be
    combined with servlet-specific multipart resolution.

    (from MF’s docs, emphasis mine)

    Also, MultipartResolver‘s bean name must be filterMultipartResolver in order to MultipartFilter run properly (or must be set via <init-param>).

    EDIT:

    As I expected in my last comment, there’s an issue with CommonsMultipartResolver which supports only POST method by default. (Actually, The method in the isMultipartContent comes in as POST even though it is a PUT as the MultipartFilter is declared before the HiddenHttpMethodFilter. as OP notes.) Below is extednded class with slighlty modified static method it uses originally:

    public class PutAwareCommonsMultipartResolver extends CommonsMultipartResolver {
    
        private static final String MULTIPART = "multipart/";
    
        @Override
        public boolean isMultipart(HttpServletRequest request) {
            return request != null && isMultipartContent(request);
        }
    
        /**
         * Utility method that determines whether the request contains multipart
         * content.
         * 
         * @param request The servlet request to be evaluated. Must be non-null.
         * 
         * @return <code>true</code> if the request is multipart; {@code false}
         * otherwise.
         * 
         * @see ServletFileUpload#isMultipartContent(HttpServletRequest)
         */
        public static final boolean isMultipartContent(HttpServletRequest request) {
            final String method = request.getMethod().toLowerCase();
            if (!method.equals("post") && !method.equals("put")) {
                return false;
            }
            String contentType = request.getContentType();
            if (contentType == null) {
                return false;
            }
            if (contentType.toLowerCase().startsWith(MULTIPART)) {
                return true;
            }
            return false;
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Spring's form tag library in a Spring MVC application that I am
I'm creating a web application using spring mvc. I have started to incorporate the
I have configured in following way that spring MVC app using Spring 3.1.1.RELEASE web.xml
we're using Spring MVC with Spring security. One of the requirements is that if
im using spring MVC and webflow to create a game server and serve some
I am using Spring MVC's SimpleFormController in conjunction with Spring MVC's form JTL to
I'm using Spring MVC for a web app. I want to use OpenID for
In a web application written using spring-MVC, I want to allow users to change
I am using Spring MVC for a web app The response time is around
I am using Spring MVC to build my web application, and I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.