码迷,mamicode.com
首页 > 编程语言 > 详细

springmvc-批量删除学习笔记

时间:2018-04-22 22:05:07      阅读:249      评论:0      收藏:0      [点我收藏+]

标签:springmvc-批量删除学习笔记

index.jsp
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <body> 
    <form action="${pageContext.request.contextPath}/emp/deleteAll.action" method="POST">
        <table border="2" align="center">
            <tr>
                <th>编号</th>
                <th>姓名</th>
            </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>嘻嘻</td>
            </tr>
            <tr>
                <td><input type="checkbox" name="ids" value="4"/></td>
                <td>笨笨</td>
            </tr>
            <tr>
                <td><input type="checkbox" name="ids" value="5"/></td>
                <td>聪聪</td>
            </tr>
            <tr>
                <td>
                    <input type="submit" value="删除"/>
                </td>
            </tr>
        </table>
    </form>
  </body>
</html>

java


import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping(value="/emp")
public class EmpAction {
    @RequestMapping(value="/deleteAll",method=RequestMethod.POST)
    public String deleteAll(Model model,int[] ids) throws Exception{
        System.out.println("需要删除的员工编号分别是:");
        for(int id : ids){
            System.out.print(id+" ");
        }

        model.addAttribute("message","批量删除员工成功");
        return "/jsp/ok.jsp";
    }
}

springmvc-批量删除学习笔记

标签:springmvc-批量删除学习笔记

原文地址:http://blog.51cto.com/357712148/2106568

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!