下面是我的代码片段:
车辆类别:
// Duplicates
private Boolean regCard = true;
private Boolean decal;
private Boolean title;
public Boolean getRegCard() {
return regCard;
}
public void setRegCard(Boolean regCard) {
this.regCard = regCard;
}
public Boolean getDecal() {
return decal;
}
public void setDecal(Boolean decal) {
this.decal = decal;
}
public Boolean getTitle() {
return title;
}
public void setTitle(Boolean title) {
this.title = title;
}蒂梅莱夫:
<form method="post" th:action="${flowExecutionUrl}" th:object="${customerModel.vehicle}">
<div class="duplicates">
<ul>
<li><label>What do you need to duplicate?</label>
<div class="regTitle">
<label>Registration Card
<input type="checkbox" th:field="*{regCard}"/>
</label>
<label>Decal
<input type="checkbox" th:field="*{decal}"/>
</label>
<div th:switch="*{vehicleType}">
<div th:case="'BR'">
<label>Title
<input th:type="checkbox" th:field="*{title}"/>
</label>
</div>
</div>
</div>
</li>
</ul>
<div class="clear"></div>
</div>
<div class="btm-btn-row">
<div class="btm-btn-left">
<a th:href="@{'~' + ${flowExecutionUrl}(_eventId='back')}">back</a>
</div>
<div class="btm-btn-right">
<input type="submit" value="continue" name="_eventId_continue" />
</div>
</div>
</form>生成的HTML:
<form method="post" action="/IllinoisRVSWeb/main-flow?execution=e1s4">
<div class="duplicates">
<ul>
<li><label>What do you need to duplicate?</label>
<div class="regTitle">
<label>Registration Card
<input type="checkbox" id="vehicle.regCard1" name="vehicle.regCard" value="true" checked="checked" /><input type="hidden" name="_vehicle.regCard" value="on" />
</label>
<label>Decal
<input type="checkbox" id="vehicle.decal1" name="vehicle.decal" value="true" /><input type="hidden" name="_vehicle.decal" value="on" />
</label>
<div>
<div>
<label>Title
<input type="checkbox" id="vehicle.title1" name="vehicle.title" value="true" /><input type="hidden" name="_vehicle.title" value="on" />
</label>
</div>
</div>
</div>
</li>
</ul>
<div class="clear"></div>
</div>
<div class="btm-btn-row">
<div class="btm-btn-left">
<a href="/IllinoisRVSWeb/main-flow?execution=e1s4&_eventId=back">back</a>
</div>
<div class="btm-btn-right">
<input type="submit" value="continue" name="_eventId_continue" />
</div>
</div>
</form>问题:
布尔值永远不会在submit上设置。我试过另一种方法。使用List对象并将该变量绑定到复选框,并为每个复选框使用适当的th:value="'SOMETEXT'“。但是这个对象也是空的。
正如您所看到的,我预先将一个值设置为true,以查看它是否会出现在html端。成功了。因此,它至少检索了值,但如果它改变了,它就不会设置它。
另外,正如您所看到的,我尝试使用“th:value=”复选框“查看这是否有帮助。但事实并非如此。
Thymeleaf版本2.1.4
春季4.1.4
弹簧WebFlow 2.4.0
任何帮助或建议都会很好。
谢谢
发布于 2015-01-02 18:46:24
SIGH...Well我找到了解决方案。
对于我所处的子流和视图状态,我很容易忽略了WebFlow xml文件。
我所拥有的:
<view-state id="duplicate" view="duplicates">
<transition on="continue" to="checkVehicleInfo" />
<transition on="back" to="finished" />
</view-state>视图状态中缺少的属性是:
model="customerModel"在使用Spring时,表单提交需要这样做
发布于 2014-12-30 19:25:34
我想可能的解决办法是:
将复选框值作为请求参数传递
<label>Registration Card
<input type="checkbox" name="retCardChecked"/>,然后在控制器中捕获它,并设置为Vehicle对象。
@RequestParam("retCardChecked") boolean retCardChecked, ...https://stackoverflow.com/questions/27710969
复制相似问题