This is Achinta, a new bee in the world of Spring. I need a small help to understand and resolve a problem which I am facing. I hope will find my answer here.
I am working on a sample Spring Web project. Here I have a Controller, Bean class and a Jsp page for UI and the other artifacts. Here is my Bean class.
@Entity
@Table(name = "tblLoadCriteria")
public class Load implements Serializable {
private Integer loadID;
private String loadCountry;
private String loadState;
private String loadCity;
private Integer totalAirVolume;
public Load() {//Constructor}
//And Getter & Setter methods for loadID, loadCountry, loadState, loadCity & totalAirVolume
}
And the Spring form in my Jsp page.
<form:formid="systemForm"commandName="load"action="${pageContext.request.contextPath}/doSothing"method="POST"><spring:messagecode="loadCountry"/>: <form:inputpath="loadCountry"/><spring:messagecode="loadState"/>: <form:inputpath="loadState"/><spring:messagecode="loadCity"/>: <form:inputpath="loadCity"/><spring:messagecode="totalAirVolume"/>: <form:inputpath="totalAirVolume"/><spring:messagecode="save"text="Save"scope="page"var="save"/><inputid="next"type="button"onClick="submitSave();"/></form:form>
And here goes the controller code
@RequestMapping(value = "/doSothing", method = RequestMethod.POST)
public String doSothing(HttpServletRequest request, HttpServletResponse response, @ModelAttribute("load") @Valid Load load ,
BindingResult result, SessionStatus sessionStatus) {
loadService.saveLoad(load);
return "forward:getApplicationRequirements";
}
Here the problem I am facing is, The "totalAirVolume" in the Load bean class is of type Integer and is bind to the UI page using spring form tags. But in the UI if I enter float value (F.Ex 12.12), instead of an integer it gives me status:400 error.
I am not so keen on javascript for validation for "totalAirVolume" field and looking for Spring way to handle it. Please help.
Your responses are highly appreciated.
Regards
Achinta
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi All,
This is Achinta, a new bee in the world of Spring. I need a small help to understand and resolve a problem which I am facing. I hope will find my answer here.
I am working on a sample Spring Web project. Here I have a Controller, Bean class and a Jsp page for UI and the other artifacts. Here is my Bean class.
Here the problem I am facing is, The "totalAirVolume" in the Load bean class is of type Integer and is bind to the UI page using spring form tags. But in the UI if I enter float value (F.Ex 12.12), instead of an integer it gives me status:400 error.
I am not so keen on javascript for validation for "totalAirVolume" field and looking for Spring way to handle it. Please help.
Your responses are highly appreciated.
Regards
Achinta