SpringMVC form标签

SpringMVC form标签

@RequiresPermissions(value={"people:student:view","people:student:add","people:student:edit"},logical=Logical.OR)
@RequestMapping(value = "form")
public String form(Student student, Model model) {
	student.setName("张小三");
	student.setAge("23");
	model.addAttribute("student", student);
	return "modules/people/student";
}

@RequiresPermissions(value={"people:student:view","people:student:add","people:student:edit"},logical=Logical.OR)
@RequestMapping(value = "form")
public String form(@ModelAttribute("student") Student student, Model model) {
	student.setName("张小三");
	student.setAge("23");
	return "modules/people/student";
}

@RequiresPermissions(value={"people:student:view","people:student:add","people:student:edit"},logical=Logical.OR)
@RequestMapping(value = "form")
public String form(@ModelAttribute("student") Student student, Model model) {
	student.setName("张小三");
	student.setAge("23");
	model.addAttribute("student", student);
	return "modules/people/student";
}

@ModelAttribute("student")这个stu是<form:form modelAttribute='student'>中的student.

<form:form action="/student/list.do" method="post" modelAttribute="student">
	<table>
		<tr>
			<td>
				<form:input path="name"/>
			</td>
			<td>
				<form:input path="age"/>
			</td>
             </tr>
	</table>
</form:form>


其它常见标签使用
Springform表单标签:form:input 、form:password、form:hidden、form:textarea:对应HTML表单的Text、password、hidden、textarea标签
form:radiobutton:单选框组建标签,对那个表单bean对应的属性和value值相等时,单选框被选中。
form:radiobuttons:单选框组件标签,用于构造多个单选框
	-items:可以是一个list、String[]或者map
	-itemValue:指定radio的value值。可以是集合中的bean的一个属性值
	-itemLabel:指定radio的label值
	-delimiter:多个单选框可以通过delimiter指定分割符
 
form:checkbox:复选框组件。用户构造单个复选框
form:checkboxs:用户构造多个复选框。使用方式同form:radiobuttons标签
form:select:用于构造下拉框组件,使用方式等同于form:radiobuttons标签
form:option :下拉框选项组件标签。使用方式等同于form:radiobuttons标签
from:errors:显示表单组件或数据校验所对应的错误

<form:form action="addUser" method="POST" modelAttribute="user">
	id:<form:input path="id"/><br>
	username:<form:input path="name" /><br>

	pwd:<form:password path="pwd" /><br>
	email:<form:input path="email" /><br>

	department:<form:select path="department.id" items="${departments}"itemLabel="name" itemValue="id"></form:select>

	<%
		HashMap<String, String> sex = new HashMap<String, String>();
		sex.put("0", "女");
		sex.put("1", "男");
		request.setAttribute("sex", sex);
	%>
	sex:<form:radiobuttons path="sex" items="${sex}" /><br>
	
	<input type="submit" value="submit">
</form:form>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值