Nin*_*Boy 6 java spring jsp spring-mvc
我使用spring,hibernate,java和jsp.我的问题是当整数值为零时,它会显示0在我的文本框中.我想只显示空字符串,但Idk如何做到这一点.请帮忙.
在我的jsp中:
<form:form method="POST" commandName="division">
...
...
<form:input path="number"/>
</form:form>
Run Code Online (Sandbox Code Playgroud)
在我的域名中:
/**
* 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;
}
Run Code Online (Sandbox Code Playgroud)
你将不得不使用spring:bind它.
此外,您将不得不使用JSTL.导入它:
<%@ taglib prefix="core" uri="http://java.sun.com/jsp/jstl/core"%>
Run Code Online (Sandbox Code Playgroud)
为了获得以下价值number:
<spring:bind path="number">
Run Code Online (Sandbox Code Playgroud)
spring:bind返回的结果是status在其value字段中调用的变量中.检查它是否为0并且什么都不打印,否则打印数字:
<core:if test="${status.value != 0}">
${status.value}
</core:if>
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请查看spring:bind文档.
| 归档时间: |
|
| 查看次数: |
2766 次 |
| 最近记录: |