Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring MVC-当整数值为零时如何显示空白文本框_Java_Spring_Jsp_Spring Mvc - Fatal编程技术网

Java Spring MVC-当整数值为零时如何显示空白文本框

Java Spring MVC-当整数值为零时如何显示空白文本框,java,spring,jsp,spring-mvc,Java,Spring,Jsp,Spring Mvc,我正在使用spring、hibernate、java和jsp。我的问题是,当整数值为零时,它会在我的文本框中显示0。我只想显示空字符串,但Idk如何显示。请帮忙 在我的jsp中: <form:form method="POST" commandName="division"> ... ... <form:input path="number"/> </form:form> 为此,您必须使用spring:bind 此外,还必须使用JSTL。通过以下方式

我正在使用spring、hibernate、java和jsp。我的问题是,当整数值为零时,它会在我的文本框中显示
0
。我只想显示空字符串,但Idk如何显示。请帮忙

在我的jsp中:

<form:form method="POST" commandName="division">
...
...
    <form:input path="number"/>
</form:form>

为此,您必须使用
spring:bind

此外,还必须使用JSTL。通过以下方式导入:

<%@ taglib prefix="core" uri="http://java.sun.com/jsp/jstl/core"%>
spring:bind
的结果在名为
status
的变量中返回,该变量位于其
value
字段中。检查是否为0,不打印任何内容,否则打印数字:

<core:if test="${status.value != 0}">
    ${status.value}    
</core:if>

${status.value}

有关更多信息,请查看。

能否向我们展示您的jsp代码和相关servlet代码?如果不检查代码,就不可能回答这些类型的问题。请将
Integer
type属性设置为not
int
。当您尝试放置一个基元
int
值时,它将自动装箱/取消装箱,当属性没有值时,您将为空,直到您显式将其设置为0。
<spring:bind path="number">
<core:if test="${status.value != 0}">
    ${status.value}    
</core:if>