I`m trying to get from Form parameter to a DTO object, i clicked on the button but nothing happaning, and it seems that the data isnt transfer
why is that?
Cntroller:
@RequestMapping(value = "/scanRequest", method = RequestMethod.POST)
public String scanRequest(@ModelAttribute("scanForm")UserRequestDTO userRequestDTO, BindingResult bindingResult, Model model) {
if (bindingResult.hasErrors()) {
return "home";
}
model.addAttribute("msg", userRequestDTO.getSellerName());
return "home";
}
DTO:
public class UserRequestDTO {
private String seller_name;
public String getSellerName() {
return seller_name;
}
public void setSellerName(String sellerName) {
seller_name = sellerName;
}
}
HTML Form:
<form:form method="POST" action="${contextPath}/requestlist" modelAttribute="scanForm" class="form-signin">
<h2 class="form-signin-heading">Create your account</h2>
<spring:bind path="seller_name">
<div class="form-group ${status.error ? 'has-error' : ''}">
<form:input type="text" path="seller_name" class="form-control" placeholder="Seller Name" autofocus="true"></form:input>
<form:errors path="seller_name"></form:errors>
</div>
</spring:bind>
<button class="btn btn-lg btn-primary btn-block" type="submit">Submit</button>
</form:form>
Update Error:
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Neither BindingResult nor plain target object for bean name 'scanForm' available as request attribute
Update Error - 2
org.apache.jasper.JasperException: org.springframework.beans.NotReadablePropertyException: Invalid property 'seller_name' of bean class [com.searcher.model.UserRequestDTO]: Bean property 'seller_name' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?