@Controller
@RequestMapping("/customers")
class CustomerController {
@RequestMapping(method = RequestMethod.POST)
public void postCustomer(HttpServletRequest request, HttpServletResponse response) throws Exception {
//processing code goes here
}
}
Handling Form Multipart Request:
If you like to handle form multipart requests, spring provides an easy way to handle this by using MultipartHttpServletRequest. This allows you to access multipart files available in the request.
To use MultipartHttpServletRequest, you can specify CommonsMultipartResolver bean in your spring xml configuration file.
<bean class="org.springframework.web.multipart.commons.CommonsMultipartResolver" id="multipartResolver">
</bean>
Once you specify you can change the signature of your controller methods to use
MultipartHttpServletRequest in place of HttpservletRequest:
@Controller
@RequestMapping("/customers")
class CustomerController {
@RequestMapping(method = RequestMethod.POST)
public void postCustomer(MultipartHttpServletRequest request, HttpServletResponse response) throws Exception {
//processing code goes here
}
}
Promote your blog
Heya¡my very first comment on your site. ,I have been reading your blog for a while and thought I would completely pop in and drop a friendly note. . It is great
ReplyDeletestuff indeed. I also wanted to ask..is there a way to subscribe to your site via email?
Form Processing