MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Iterator it = (Iterator) multipartRequest.getFileNames();
String fileName = it.next();
MultipartFile file = multipartRequest.getFile(fileName);
String ext = fileName.substring(fileName.lastIndexOf("."));
if(ext.equalsIgnoreCase(".pdf")) {
//do something
}
else
{
//do something
}