springmvc教程-将请求中的参数封装到数组中

介绍

比如批量删除等

html代码:

<form action="/student/deleteByIds" method="post">
    <input type="submit" value="批量删除">
<table>
    <tr>
        <td></td>
        <td>姓名</td>
    </tr>
    <tr>
        <td><input type="checkbox" name="ids" value="1"></td>
        <td>李雷</td>
    </tr>
    <tr>
        <td><input type="checkbox" name="ids" value="2"></td>
        <td>韩梅梅</td>
    </tr>
    <tr>
        <td><input type="checkbox" name="ids" value="3"></td>
        <td>lucy</td>
    </tr>
</table>
</form>

Controller代码:

@RequestMapping("/deleteByIds")
public String deleteByIds(String[] ids){
    for(Object id:ids){
        System.out.println(id);
    }
    return "deleteSuccess";
}

原文出处:/show_1IXiajefXuW.html