Im using spring, hibernate, java, and jsp. My problem is that when the integer value is zero it displays 0
in my textbox. I want to display only empty string but Idk how to do it. Please help.
In my jsp:
<form:form method="POST" commandName="division">
...
...
<form:input path="number"/>
</form:form>
In my domain:
/**
* Get the number of the division.
* @return The number.
*/
@Column(name = "NUMBER")
public int getNumber() {
return number;
}
/**
* Set the number of the division.
* @param number The division number.
*/
public void setNumber(int number) {
this.number = number;
}
You will have to use spring:bind
for that.
Also, you will have to use JSTL. Import it with:
<%@ taglib prefix="core" uri="http://java.sun.com/jsp/jstl/core"%>
In order to get the value for number
:
<spring:bind path="number">
The result of the spring:bind
is returned in a variable called status
, in its value
field. Check if it is 0 and print nothing, else print the number:
<core:if test="${status.value != 0}">
${status.value}
</core:if>
For more information, take a look at the spring:bind documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With