Spring MVC - Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Integer'
<p>Am new to Spring MVC. I have developed a sample application which performs SELECT, INSERT, UPDATE and DELETE.</p>

<p><strong>Below is my Bean class</strong></p>

<pre><code>@Id
@Column
private int student_id;
private String name;
private String age;
private String city;
private String country;
private Integer phone;
private int hsc;
private int sslc;
private int college;

/*getter and setters*/
</code></pre>

<p><strong>Below is my Controller Class</strong></p>

<pre><code>@Controller
public class StudentController {

private static final Logger logger = Logger.getLogger(StudentController.class);

@Autowired
private StudentService studentService;

@RequestMapping(value = "/students", method = RequestMethod.GET)
public String listStudents(Model model){
    if(logger.isDebugEnabled()){
        logger.debug("listStudents method is executed!");
    }

    logger.error("This is an error message", new Exception("Testing"));
    model.addAttribute("student", new StudentDO());
    model.addAttribute("listStudents", this.studentService.listStudents());
    return "students";
}


@RequestMapping(value = "/students/add", method = RequestMethod.POST)
public String addStudent(@ModelAttribute("student") StudentDO studentDO){
    if(studentDO.getStudent_id() == 0){
        /**new person, add it*/
        this.studentService.addStudent(studentDO);
    }else{
        /**existing person, call update*/
        this.studentService.updateStudent(studentDO);
    }
    return "redirect:/students";
}
}
</code></pre>

<p><strong>Below is my JSP page</strong></p>

<pre><code>&lt;c:url var="addAction" value="/students/add" &gt;&lt;/c:url&gt;

&lt;form:form action="${addAction}" commandName="student"&gt;

&lt;table&gt;

&lt;c:if test="${!empty student.name}"&gt;
    &lt;tr&gt;
        &lt;td&gt;
            &lt;form:label path="student_id"&gt;
                &lt;spring:message text="STUDENT_ID"/&gt;
            &lt;/form:label&gt;
        &lt;/td&gt;
        &lt;td&gt;
            &lt;form:input path="student_id" readonly="true" size="8"  disabled="true" /&gt;
            &lt;form:hidden path="student_id" /&gt;
        &lt;/td&gt;
    &lt;/tr&gt;
&lt;/c:if&gt;

&lt;tr&gt;
    &lt;td&gt;
        &lt;form:label path="name"&gt;
            &lt;spring:message text="Name"/&gt;
        &lt;/form:label&gt;
    &lt;/td&gt;
    &lt;td&gt;
        &lt;form:input path="name" /&gt;
    &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;
        &lt;form:label path="age"&gt;
            &lt;spring:message text="Age"/&gt;
        &lt;/form:label&gt;
    &lt;/td&gt;
    &lt;td&gt;
        &lt;form:input path="age" /&gt;
    &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;
        &lt;form:label path="city"&gt;
            &lt;spring:message text="City"/&gt;
        &lt;/form:label&gt;
    &lt;/td&gt;
    &lt;td&gt;
        &lt;form:input path="city" /&gt;
    &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;
        &lt;form:label path="country"&gt;
            &lt;spring:message text="Country"/&gt;
        &lt;/form:label&gt;
    &lt;/td&gt;
    &lt;td&gt;
        &lt;form:input path="country" /&gt;
    &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;
        &lt;form:label path="phone"&gt;
            &lt;spring:message text="Phone"/&gt;
        &lt;/form:label&gt;
    &lt;/td&gt;
    &lt;td&gt;
        &lt;form:input path="phone" /&gt;
    &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;
        &lt;form:label path="hsc"&gt;
            &lt;spring:message text="HSC"/&gt;
        &lt;/form:label&gt;
    &lt;/td&gt;
    &lt;td&gt;
        &lt;form:input path="hsc" /&gt;
    &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;
        &lt;form:label path="sslc"&gt;
            &lt;spring:message text="SSLC"/&gt;
        &lt;/form:label&gt;
    &lt;/td&gt;
    &lt;td&gt;
        &lt;form:input path="sslc" /&gt;
    &lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
    &lt;td&gt;
        &lt;form:label path="college"&gt;
            &lt;spring:message text="College"/&gt;
        &lt;/form:label&gt;
    &lt;/td&gt;
    &lt;td&gt;
        &lt;form:input path="college" /&gt;
    &lt;/td&gt;
&lt;/tr&gt;

&lt;tr&gt;
    &lt;td colspan="2"&gt;
        &lt;c:if test="${!empty student.name}"&gt;
            &lt;input type="submit" value="&lt;spring:message text="Edit Student"/&gt;" /&gt;
        &lt;/c:if&gt;
        &lt;c:if test="${empty student.name}"&gt;
            &lt;input type="submit" value="&lt;spring:message text="Add Student"/&gt;" /&gt;
        &lt;/c:if&gt;
    &lt;/td&gt;
&lt;/tr&gt;
</code></pre>

<p>
</p>

<p>Now am facing two issues.
1. After entering the values and clicked Add Student button, am getting the below error.</p>

<pre><code>org.springframework.validation.BindException:     
org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'student' on field 'phone': rejected value [9962287970]; 
codes [typeMismatch.student.phone,typeMismatch.phone,typeMismatch.java.lang.Integer,typeMismatch]; 
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [student.phone,phone]; arguments []; 
default message [phone]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.lang.Integer' for property 'phone'; 
nested exception is java.lang.NumberFormatException: For input string: "9962287970"]
</code></pre>

<ol start="2">
<li>By default values which I have declared as int are being displayed in my JSP by default as 0. When I changed the phone variable from int to Integer, 0 dint come. Why is it like this?</li>
</ol>