Announcement Announcement Module
Collapse
No announcement yet.
problem in getSpring MVC3 getting values from the form and to load with Domine object Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • problem in getSpring MVC3 getting values from the form and to load with Domine object

    I am getting the below exception kindly help i got stuck up with this for a day

    org.springframework.beans.NotReadablePropertyExcep tion: Invalid property 'fcode' of bean class [java.lang.String]: Bean property 'featurecode' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?

    My form jsp(addData.jsp)

    <form:form commandName="addData" method="POST" >
    <div>
    <div>
    <p>

    <input type="text" path="fcode" >


    </p>
    <table width="30%" align="center">
    <tr align="center">
    <td><input type="button" onclick="location.href='<c:url value="/checkDataList.htm"/>'" value="Save"/></td>
    </tr>
    </table>


    </div>
    </div>
    </form:form>

    My Domine object:

    import java.io.Serializable;

    public class AddData implements Serializable{

    /**
    *
    */
    private static final long serialVersionUID = 1L;

    private String fcode;

    public String getFcode() {
    return fcode;
    }
    public void setFcode(final String fcode) {
    this.fcode = fcode;
    }

    My controller class details:


    @RequestMapping("/checkDataList")
    public String addData(
    @ModelAttribute("addData") AddData addData,
    BindingResult result, HttpServletRequest request,
    HttpServletResponse response) throws Exception {


    String fcode = addData.getfcode();

    System.out.println(fcode);

    // DataService.saveData(addData);
    return "redirect:/DataList.htm";
    }
    Last edited by swam; Dec 6th, 2011, 08:49 AM.

  • #2
    Please use [ code][/code ] tags when posting code.

    Use the form tags to render your input tag that will give you the proper path to do binding (it should be something like appData.fdata).

    Comment


    • #3
      Marten thanks as adviced by i used the same

      <form:form commandName="addData" method="POST" >
      <div>
      <div>
      <p>

      <form:input type="text" path="addData.fcode" >


      </p>
      <table width="30%" align="center">
      <tr align="center">
      <td><input type="button" onclick="location.href='<c:url value="/checkDataList.htm"/>'" value="Save"/></td>
      </tr>
      </table>


      But still i am getting the same error,any other thing i need to do..?

      Comment


      • #4
        when we use location.href will be a new request rather than form submission.
        so, better to use form submission.

        Comment


        • #5
          I suggest a read of the reference guide.

          path if fcode NOT addData.fcode if you use the form tags.. It is only addData.fcode if you do NOT use the form tags.

          Comment

          Working...
          X