Announcement Announcement Module
Collapse
No announcement yet.
How @ModelAttribute extracts multipart-data parameters ? Not file. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How @ModelAttribute extracts multipart-data parameters ? Not file.

    Hi,

    I would like to know the exact class that is used for extracting parameters of type multipart-data used by @ModelAttribute.

    The situation is like this:

    For searching a record, the parameters supplied from web is bound using the following code snippet:

    Code:
    @RequestMapping(value = "product/search")
    public ModelAndView retrieveProductList(
    @ModelAttribute(searchproductformString) final ManageProductForm searchproductform,
    final BindingResult result)
    Here, the parameters (eg. The supplied name of product from frontend) is sent as multipart-data, not as regular HTTPServletRequest's parameters. So, something like DefaultMultipartHttpServletRequest present in org.springframework.web.multipart.support is being used to convert that multipart-data to String objects and then extract them.

    Can anyone please pinpoint the exact class being employed by Spring for this?
    Just to be clear, this is not related to file upload using multipart-data but is about supplying plain parameters-values using multipart-data and extraction in Spring.

  • #2
    You can use:

    Code:
    @RequestParam CommonsMultipartFile file
    then access the String values like this:

    Code:
    String name = file.getOriginalFileName()
    Tell me if that does not fit your question.

    Comment

    Working...
    X