addtab.jsp

来自「程序为种种闪字图程序试用版,本程序采用JSP+MSSQL开发」· JSP 代码 · 共 58 行

JSP
58
字号
<%@ page pageEncoding="GB2312"%>
<%@ page contentType="text/html" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ include file="ispass.jsp" %>
<%out.clear();%>
<fmt:requestEncoding value="gb2312" />
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>添加关键字</title>
<link href="images/css.css" rel="stylesheet" type="text/css">
</head>

<body>
<c:set var="urls" value="<%=request.getHeader("Referer")%>" />
<c:catch var="isok">
<c:set var="isAdd" value="true" />
<%--检测相关参数是否正确--%>
<c:if test="${empty fn:trim(param.tabname)}">
	<c:set var="errorMsg" scope="request" value="请填写关键字" />
	<c:set var="isAdd" value="false" />
</c:if>


<%-- 检测是否有通过,否则重定向 --%>
<c:choose>
	<c:when test="${isAdd}">
    	<sql:query var="istab">
        	Select * from tab where tabname = ?
            <sql:param value="${fn:trim(param.tabname)}"/>
        </sql:query>
        <c:if test="${istab.rowCount <= 0}">
            <%-- 更新数据库 --%>
            <sql:update>
                insert into tab (tabname,click) values (?,?)
                <sql:param value="${fn:trim(param.tabname)}" />
                <sql:param value="0" />
             </sql:update>
            <c:set var="errorMsg" scope="request" value="送键字添加成功" />
        </c:if>
        <c:if test="${istab.rowCount > 0}">
        	<c:set var="errorMsg" scope="request" value="关键字已经存在" />
        </c:if>
	</c:when>
</c:choose>
<jsp:forward page="tablist.jsp" />
</c:catch>
<c:if test="${!empty isok}">
	<c:set var="errorMsg" scope="request" value="对不起参数提交错误,请返回另行操作!" />
	<c:set var="errorUrl" scope="request" value="${urls}" />
	<jsp:forward page="error.jsp" />
</c:if>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?