How to bind file in spring and upload file in folder
<p>I have a problem in binding files in spring. I was trying to save files in a folder and saving files name in the database. But I am getting some error while binding files in form.</p>

<p>@Controller</p>

<pre><code>@RequestMapping(value="/addStudent",method=RequestMethod.POST)
public String saveStudent(@RequestParam("images") MultipartFile files,@ModelAttribute("addstd") StudentInfo theStudent,Model model){
      String fileName=null; 

    if(!files.isEmpty()){

        try {
            String path= session.getServletContext().getRealPath("/WEB-INF/resources/images");
            String newName=String.valueOf(new java.util.Date().getTime());
            fileName=files.getOriginalFilename();
            String ext=FilenameUtils.getExtension(fileName);
            File imageFile=new File(path,newName+"."+ext);
            files.transferTo(imageFile);
            theStudent.setImages(newName+"."+ext);

        } catch (Exception e) {

        }
    }
    studentService.saveStudent(theStudent);
    return "redirect:/login";
}
</code></pre>

<p>Database class</p>

<pre><code>@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="id")
private int id;

@Column(name="year_id")
private int year;


@Column(name="faculty_id")
private int faculty;

@Column(name="firstname")
private String firstName;

@Column(name="lastname")
private String lastName;

@Column(name="contact_no")
private String contact_No;

@Column(name="address")
private String address;

@Column(name="email")
private String email;

@Column(name="images")
private String images;
</code></pre>

<p>My jsp page is:</p>

<pre><code>    &lt;form:form action="addStudent" enctype="multipart/form-data" modelAttribute="addstd" method="POST"&gt;    
    &lt;form:hidden path="id" /&gt;
    &lt;form:input path="firstName" placeholder="Fistname" /&gt;
    &lt;form:input path="lastName" placeholder="Lastname" /&gt;
    &lt;form:input path="contact_No" placeholder="Contact Number" /&gt;
    &lt;form:input path="address" placeholder="Address" /&gt;
    &lt;form:input path="email" placeholder="Email" /
    Year:

    &lt;form:select path="year"&gt;
            &lt;c:forEach var="temp" items="${studentyear}"&gt;
            &lt;form:option value="${temp.yearId}"&gt;${temp.year}&lt;/form:option&gt;
            &lt;/c:forEach&gt;
        &lt;/form:select&gt;   

      Faculty: 
        &lt;form:select path="faculty"&gt;
            &lt;c:forEach var="temp" items="${studentfaculty}"&gt;
            &lt;form:option value="${temp.faculty_id}" &gt;${temp.faculty}&lt;/form:option&gt;
            &lt;/c:forEach&gt;
        &lt;/form:select&gt;
      Profile: &lt;form:input type="file" path="images"  /&gt;

    &lt;input type="submit" value="Add/Update Record" class="button" /&gt;
&lt;/form:form&gt;
</code></pre>

<p>In this code I am getting the error "The request sent by the client was syntactically incorrect."</p>