springMVC表单中path属性小记

如何给表单赋值:
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;
}

即可在页面中获取到查询的指定字段的值

猜你喜欢

转载自blog.csdn.net/qq_39822451/article/details/83863706