2016-11-12 39 views
0

我正在使用以下表单来保存用户信息。如何在重复使用相同的表单时隐藏表单域

<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form"%> 

<sf:form action="someAction"method="post" commandName="backingBean"> 
    <sf:input type="hidden" name="userId" path="userId" /> 
    <sf:input type="text" placeholder="Username" name="username" path="username" /> 
    <sf:input placeholder="Password" path="password" type="password" name="password" /> 
    <sf:input placeholder="Email" name="email" type="email" path="email" /> 
    <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}" /> 
    <button type="submit" class="btn btn-default">Submit</button> 
</sf:form> 

当用户想要编辑他们的信息时,我使用隐藏的userId发送给他们相同的表单。但是这次我不希望在表单中显示密码。我怎么做。

回答

0

你可以用<c:choose><c:when..测试一个条件,你想要做什么尝试:“不显示在表格申请密码”

+0

我有一个域类和类有一定的验证。如果我使用那么该字段是隐藏的,但是当我提交表单时,会显示一些验证消息并显示密码字段,并显示一些消息,如“密码应包含5个字符”。此消息我设置了一些属性文件以显示验证错误消息。我处理这个? – torikraju

+0

那么可能你必须将定义表单的类更改为一个类,其中密码字段是可选的或根本不存在,然后在成功验证时将属性复制到域对象 –