springMVC表單中path屬性小記
阿新 • • 發佈:2018-11-12
如何給表單賦值:
1、controller:
Map<String,Object> advertise = b008003Service.findAdvertise(sn);
// 欄位set
b008003Bean.setLgReward(advertise.get("lgReward").toString());
model.addAttribute("b008003Bean", b008003Bean);
return "/b008/b008003";
2、jsp頁面:
<sf:form action="<%=updateAction%>" role="form" method="post" commandName="b008003Bean" class="form-horizontal"> <div class="form-group"> <label class="col-sm-2 control-label">聯盟獎勵:</label> <div class="col-sm-8"> <sf:input type="text" onkeyup="this.value= this.value.match(/\d+(\.\d{0,2})?/) ? this.value.match(/\d+(\.\d{0,2})?/)[0] : ''" path="lgReward" placeholder="聯盟獎勵額度" class="form-control"/> // 同名欄位 </div> </div> </sf:form>
3、bean中:
public class B008003Bean {
/** 同名欄位 */
@Digits(integer = 8, fraction = 2)
private String lgReward;
}
即可在頁面中獲取到查詢的指定欄位的值