📄 teachlession_add_insert.jsp
字号:
<%@ page contentType="text/html;charset=GB2312" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<html>
<body bgcolor="#DCDADA">
<!-------作插入操作的SQL语句-------->
<c:set var="insertSQL" value="insert into teachlession(lession_id,teacher_id) values(?,?)"/>
<!------设置数据源------>
<sql:setDataSource dataSource="jdbc/sqlserver" var="sqlDS"/>
<!------作数据库操作------>
<c:if test="${(not empty param.lession_id) and (not empty param.teacher_id)}">
<c:set var="selectSQL"
value="select * from teachlession where lession_id=? and teacher_id=?"/>
<!--查询数据库中的数据,看是否已存在此条数据-->
<sql:query sql="${selectSQL}"
var="teachlessionRS" dataSource="${sqlDS}">
<sql:param value="${param.lession_id}"/>
<sql:param value="${param.teacher_id}"/>
</sql:query>
<!--如果不存在则插入-->
<c:if test="${teachlessionRS.rowCount<1}">
<sql:update sql="${insertSQL}"
var="infecCount" dataSource="${sqlDS}">
<sql:param value="${param.lession_id}"/>
<sql:param value="${param.teacher_id}"/>
</sql:update>
<c:if test="${infecCount==1}">
增加教师授课信息成功!
</c:if>
<c:if test="${infecCount!=1}">
增加教师授课信息失败!
</c:if>
</c:if>
<!--如果已存在-->
<c:if test="${teachlessionRS.rowCount>=1}">
此教师授课信息已存在!
</c:if>
</c:if>
<br><a href="teachlessionman.jsp">返回</a>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -