需求:点击下拉框里的数字,即可刷新页面同时更改页面展示数据的大小
使用select标签+a标签 导致a标签不起作用!!!)
错误展示:
<select class="form-control" >
<option th:selected="${pageSize==5}" th:text="5">
<a th:href="@{'/dynamic_table'+${pageSize}=5}">5</a>
</option>
<option th:selected="${pageSize==5}" th:text="10">
<a th:href="@{'/dynamic_table'+${pageSize}=5}">10</a>
</option>
</select>
正确展示:
<select class="form-control" size="1" name="dynamic-table_length" onchange="window.location=this.value" >
<option value="/dynamic_table?pageSize=5" th:selected="${pageSize==5}" >5</option>
<option value="/dynamic_table?pageSize=10" th:selected="${pageSize==10}">10</option>
控制器:
public String dynamic_table(Model model,@RequestParam(value="pageSize" ,required=false) Integer pageSize)