Rectangle 27 0

java Spring web application getting form data post method?


<form:form method="POST" 
    action="${contextPath}/scanRequest" 
    modelAttribute="scanForm"  class="form-signin">...
<form:form method="POST" 
action="${contextPath}/requestlist/scanRequest" 
modelAttribute="scanForm"  class="form-signin">...
@ModelAttribute("scanForm")
public UserRequestDTO getScanForm(){
  return new UserRequestDTO();
}
public String getSellerName() {
        return seller_name;
    }
public String getSeller_name() {
    return seller_name;
}

@Guyb check my edit , dude your getter is wrong, the convention is get+firtLetterto uppercase+the rest of the name of your attribute

@Guyb you are welcome , can you mark it as an answer

I added it but another Error, I dont understand what i`m doing wrong..

Your scanForm is not present when rendering the page containing the form, so you have to add it, add this method to your controller :

if /requestlist is the request Mapping of your controller (the one who contains the method scanRequest) than change your form to :

if is is not and your controller do

this is not a proper getter for attribute seller_name change it to

your post entry point is /scanRequest but your submitting to /requestlist, it fails cause you are not targeting the right mapped method .

Note