查看JSTL的doc解决问题
感觉JSTL这些东西的API远比java的api难找多了,不过终究是有办法的,google:jstl documentation,进入http://docs.oracle.com/javaee/5/jstl/1.1/docs/tlddocs/index.html
然后查找sql/update的API,解决了使用<sql:update>的问题,我最开始以为删除掉的记录集合被存放在var域中,查看了API之后才知道原来是删除掉的记录数被存放在var域
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://www.mldn.cn/jst/core" %> <%@ taglib prefix="sql" uri="http://www.mldn.cn/jst/sql" %> <%@ page import="java.util.*" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <form action="disp_delete_by_empno.jsp" method="post"> 输入雇员编号:<input type="text" name="empno"> <input type="submit" value="submit"> </form> </body> </html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ page import="java.util.*" %> <%@ taglib prefix="c" uri="http://www.mldn.cn/jst/core"%> <%@ taglib prefix="sql" uri="http://www.mldn.cn/jst/sql"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> <!-- 你也可以先查询,把匹配的结果显示出来,然后再做一次删除 --> <c:if test="${param.empno!=null && param.empno!='' }"> <sql:setDataSource dataSource="jdbc/mldn" var="mldnds"/> <sql:update var="result" dataSource="${mldnds }"> DELETE FROM emp WHERE empno=${param.empno }; </sql:update> </c:if> <h3>一共删除了${result}条记录!</h3> <!-- 注意这里没有用result.rowCount! 查看JSTL关于update var域的doc! --> </body> </html>