title: Creating multiple pages in spring mvc using annotation
body: <p>I want to create a sample project in spring mvc using the annotation method where the user can navigate to one page to another by clicking buttons.I am new to spring mvc i had created a sample project for single page display</p>
  
  <p>I am expecting your help.
  Thanks in advance</p>
  
  <p>Login.java</p>
  
  <pre><code> package credentials;
  
   public class Login {
  
  private String name;
  private String password;
  
  public void setName(String name){
      this.name=name;
  }
  public String getName(){
      return name;
  }
  
  public void setPassword(String password){
      this.password=password;
  }
  public String getPassword(){
      return password;
  }
    }
  </code></pre>
  
  <p>Logincontroller.java</p>
  
  <pre><code>     package credentials;
  
      import org.apache.tomcat.jdbc.pool.Validator;
        import org.springframework.stereotype.Controller;
         import org.springframework.ui.ModelMap;
       import org.springframework.validation.BindingResult;
        import org.springframework.web.bind.annotation.ModelAttribute;
      import org.springframework.web.bind.annotation.RequestMapping;
       import org.springframework.web.bind.annotation.RequestMethod;
      import org.springframework.web.servlet.ModelAndView;
  
  
       @Controller
      public class LoginController {
  
  @RequestMapping(value="/login")
  public ModelAndView login(){
      return new ModelAndView("login","command",new Login());
  
  }
  
  
  
  @RequestMapping(value="/calc")
  public ModelAndView Add(){
      return new ModelAndView("calc","command",new Login());
  
  }
  
  
      }
  </code></pre>
  
  <p>login.jsp</p>
  
  <pre><code>       &lt;%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt;
  
         &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
      &lt;html&gt;
       &lt;head&gt;
       &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
       &lt;title&gt;Insert title here&lt;/title&gt;
     &lt;/head&gt;
      &lt;body&gt;
      &lt;h2&gt;Login here&lt;/h2&gt;
      &lt;form:form method="POST" action="calc"&gt;
      &lt;table&gt;
      &lt;tr&gt;
       &lt;td&gt;&lt;form:label path="name"&gt;Name&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="password"&gt;Password&lt;/form:label&gt;&lt;/td&gt;
       &lt;td&gt;&lt;form:password path="password"&gt;&lt;/form:password&gt;&lt;/td&gt;
  
        &lt;/tr&gt;
         &lt;tr&gt;
         &lt;td colspan="2"&gt;
           &lt;input type="submit" value="login" /&gt;
         &lt;/td&gt;  
  
         &lt;/table&gt;
  </code></pre>
  
  <p>calc.jsp
           &lt;%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%></p>
  
  <pre><code>     &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"      "http://www.w3.org/TR/html4/loose.dtd"&gt;
         &lt;html&gt;
          &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
           &lt;title&gt;Insert title here&lt;/title&gt;
           &lt;/head&gt;
           &lt;body&gt;
           &lt;form:form method="POST" action="content"&gt;
           &lt;h2&gt;Add content&lt;/h2&gt;
           &lt;table&gt;
  
           &lt;tr&gt;
           &lt;form:button path="mouse" value="Mouse"&gt;Mouse&lt;/form:button&gt;
  
          &lt;td&gt;
  
              &lt;/tr&gt;
         &lt;/table&gt;
        &lt;/form:form&gt;
        &lt;/body&gt;
        &lt;/html&gt;
  </code></pre>
  
  <p>content.jsp</p>
  
  <pre><code>    &lt;%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt;
  
        &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
         &lt;html&gt;
         &lt;head&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
       &lt;title&gt;Insert title here&lt;/title&gt;
        &lt;/head&gt;
         &lt;body&gt;
        &lt;h2&gt;Submitted Student Information&lt;/h2&gt;
  
  
          &lt;/body&gt;
            &lt;/html&gt;
  </code></pre>
  
  <p>when this "Mouse" button on calc page is clicked the following error occurs</p>
  
  <pre><code>      HTTP Status 404 - 
  </code></pre>
  
  <hr>
  
  <pre><code>    type Status report
  
      message 
  
     description The requested resource is not available.
  </code></pre>
  
  <p>After adding</p>
  
  <pre><code>    &lt;form:input path="mouse"/&gt;
  </code></pre>
  
  <p>the following error occured when clicking login button in login page</p>
  
  <pre><code>         HTTP Status 500 - An exception occurred processing JSP page /WEB-INF/jsp/calc.jsp  at line 16
  </code></pre>
  
  <hr>
  
  <pre><code>     type Exception report
  
         message An exception occurred processing JSP page /WEB-INF/jsp/calc.jsp at line 16
  
          description The server encountered an internal error that prevented it from fulfilling this request.
  </code></pre>
  
  <p>exception </p>
  
  <pre><code>            org.apache.jasper.JasperException: An exception occurred processing JSP page /WEB-INF/jsp/calc.jsp at line 16
  
          13: 
          14: &lt;tr&gt;
          15:   &lt;form:button path="mouse" value="Mouse"&gt;Mouse&lt;/form:button&gt;
          16:    &lt;form:input path="mouse"/&gt;
          17: &lt;td&gt;
          18: 
          19: &lt;/tr&gt;
  
  
     Stacktrace:
         org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:470)
  org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
  org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
  org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
  org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
  org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180)
  org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
  org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
  org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
  
  
   root cause 
  
      org.springframework.beans.NotReadablePropertyException: Invalid property 'mouse' of     bean class [credentials.Login]: Bean property 'mouse' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?
  org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:729)
  org.springframework.beans.BeanWrapperImpl.getPropertyValue(BeanWrapperImpl.java:721)
  org.springframework.validation.AbstractPropertyBindingResult.getActualFieldValue(AbstractPropertyBindingResult.java:99)
  org.springframework.validation.AbstractBindingResult.getFieldValue(AbstractBindingResult.java:219)
  org.springframework.web.servlet.support.BindStatus.&lt;init&gt;(BindStatus.java:120)
  org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:178)
  org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:198)
  org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:164)
  org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:151)
  org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:142)
  org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:126)
  org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:421)
  org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:142)
  org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:102)
  org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79)
  org.apache.jsp.WEB_002dINF.jsp.calc_jsp._jspx_meth_form_005finput_005f0(calc_jsp.java:201)
  org.apache.jsp.WEB_002dINF.jsp.calc_jsp._jspx_meth_form_005fform_005f0(calc_jsp.java:126)
  org.apache.jsp.WEB_002dINF.jsp.calc_jsp._jspService(calc_jsp.java:81)
  org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
  org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
  org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
  org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
  org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
  org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
  org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180)
  org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
  org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
  org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
  org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
  javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
  </code></pre>