Results 1 to 5 of 5

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

  1. #1
    Join Date
    Dec 2011
    Posts
    4

    Default 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 at 07:49 AM.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    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).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Dec 2011
    Posts
    4

    Default

    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..?

  4. #4
    Join Date
    Jul 2011
    Posts
    9

    Default

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

  5. #5
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •