Spring Boot Thymeleaf GetParameter
如何到达控制器用户在html中输入数据-复选框并选择列表。我用过百里香和春靴Spring Boot Thymeleaf GetParameter,spring,spring-boot,thymeleaf,getparameter,Spring,Spring Boot,Thymeleaf,Getparameter,如何到达控制器用户在html中输入数据-复选框并选择列表。我用过百里香和春靴 <form id="register-form" th:object="${worker}" th:action="@{/worker/save}" method="post" role="form">
<form id="register-form" th:object="${worker}" th:action="@{/worker/save}"
method="post"
role="form">
<div class="form-group">
<input type="text" th:field="*{firstName}" id="firstName" tabindex="1"
class="form-control" placeholder="First Name" value=""/>
</div>
<div class="form-group">
<input type="text" th:field="*{secondName}" id="secondName" tabindex="1"
class="form-control" placeholder="Second Name" value=""/>
</div>
<div class="form-group">
<input class="form-control" placeholder="Date of Bithday" type="text"
th:field="*{dateBirth}" id="datepicker"/>
</div>
<div class="form-group">
<label class="checkbox-inline">
<input type="checkbox" value="java"/>JAVA Skill
</label>
<select class="form-control" id="exampleSelect1">
<option value=""></option>
<option value="first"> First level</option>
<option value="second"> Second level</option>
<option value="third"> Third level</option>
<option value="fourth"> Fourth level</option>
<option value="fifth"> Fifth level</option>
</select>
</div>
<div class="form-group">
<label class="checkbox-inline">
<input th:field="*{phpSkill}" type="checkbox" value="php"/>PHP Skill
</label>
<select class="form-control" id="exampleSelect2">
<option value=""></option>
<option value="first"> First level</option>
<option value="second"> Second level</option>
<option value="third"> Third level</option>
<option value="fourth"> Fourth level</option>
<option value="fifth"> Fifth level</option>
</select>
</div>
<div class="form-group">
<label class="checkbox-inline">
<input th:field="*{javascriptSkill}" type="checkbox"
value="javascript"/>JAVA
SCRIPT Skill
</label>
<select class="form-control" id="exampleSelect3">
<option value=""></option>
<option value="first"> First level</option>
<option value="second"> Second level</option>
<option value="third"> Third level</option>
<option value="fourth"> Fourth level</option>
<option value="fifth"> Fifth level</option>
</select>
</div>
<hr/>
<div class="form-group">
<div class="row">
<div class="col-sm-6 col-sm-offset-3">
<input type="submit" name="register-submit" id="register-submit"
tabindex="4" class="form-control btn btn-register"
value="Register Now"/>
</div>
</div>
</div>
</form>
如果您在复选框中使用javaSkill和level并选中,那么您的模型“worker”应该具有带有getter和setter的变量 复选框:
<input type="checkbox" name="javaSkill" th:checked="*{javaSkill}" />
选择:
<select th:field="*{level}">
<option th:value="first" th:text="First Level"></option>
<option th:value="second" th:text="Second Level"></option>
</select>
下面是一个简单有效的下拉菜单示例 示例
--选择位置--
波士顿
纽约
芝加哥
旧金山
如果访问控制器中的位置
值,则可以获得下拉值
复选框中也有类似的选项
<select th:field="*{level}">
<option th:value="first" th:text="First Level"></option>
<option th:value="second" th:text="Second Level"></option>
</select>
<select class="form-control" th:value="${appointment.location}" name="location" id="location">
<option disabled="disabled" selected="selected" > -- select the location --</option>
<option>Boston</option>
<option>New York</option>
<option>Chicago</option>
<option>San Francisco</option>
</select>