⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 admin_edit_bbs.jsp

📁 自己编写的jsp+mysql论坛系统,带后台系统.不是很完善,但是功能是完整的
💻 JSP
字号:
<%@ page language="java" contentType="text/html; charset=GBK"
	pageEncoding="GBK"%>
<%@page import="java.util.*,java.io.*,java.sql.*"%>
<%@ include file="../conn.jsp"%>
<!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=GBK">
		<title>修改帖子</title>
	</head>
	<body>
		&nbsp;
		<!-- 载入页头 -->
		<jsp:include page="admin_include.jsp"></jsp:include>
		<%
			int tmp = 0;
			String vcode = "";
			//生成验证码 1001-9999
			do {
				tmp = (int) (Math.random() * 10000 - 1);
			} while (tmp <= 1000);
			vcode = String.valueOf(tmp);
		%>
		<script type="text/javascript">
		function check(){
		if(form.title.value==""){
			alert("请输入标题!");
			return false;
		}
		if(form.vcode.value!=<%=vcode%>){
			alert("验证码不正确!");
			return false;
		}
		}
		</script>
		<%
			String username = "";
			if (null != session.getAttribute("adminlogin")) {
				String id = "";
				//接收帖子id参数
				if (null != request.getParameter("id")) {
					id = request.getParameter("id").toString();
					try {
						String author = "";
						String title = "";
						String content = "";
						String strDo = "";

						strDo = "SELECT * FROM " + tbbs + " WHERE id='" + id
								+ "'";
						rs = stmt.executeQuery(strDo);
						if (rs.next()) {
							author = rs.getString("author");
							title = rs.getString("title");
							content = rs.getString("content");
						}
						rs.close();
						//字符过滤&处理
						title = title.replaceAll("&nbsp;", " ");
						title = title.replaceAll("&sd", "'");
						title = title.replaceAll("&dd", "\"");
						//字符串开头为双引号处理
						if (title.substring(0, 1).equals("\"")) {
							title = title.substring(1, title.length());
						}
						content = content.replaceAll("&sd", "'");
						content = content.replaceAll("&dd", "\"");
						content = content.replaceAll("<br/>", "\n");
						content = content.replaceAll("&nbsp;", " ");
		%>
		<form name="form" action="admin_edit_bbs_Action.jsp" method="post"
			onsubmit="return check()">
			帖子编号:
			<font color="blue"><%=id%></font>
			<input type="hidden" value=<%=id%> name="id">
			<br>
			<br>
			标题:
			<br>
			<br>
			<input type="text" maxlength="50" size="80" name="title"
				value="<%=title%>">
			<br>
			<br>
			作者:
			<font color="blue"><%=author%></font>
			<br>
			<br>
			<font color="red">内容最大长度1000字符</font>
			<br>
			<textarea name="content" rows="10" cols="80"><%=content%></textarea>
			<br>
			<p>
				验证码:
				<input type="text" maxlength="4" size="4" name="vcode">
				<font color="red"><%=vcode%></font>
			</p>
			<br>
			<input type="submit" name="submit" value="提交">
			<input type="reset" name="reset" value="重置">


		</form>
		<%
			} catch (Exception e) {
						e.printStackTrace();
						response.sendRedirect("../error.jsp");
					} finally {
						stmt.close();
						conn.close();
					}
				} else {
					response.sendRedirect("../error.jsp");
				}
			} else {
				response.sendRedirect("../error.jsp");
			}
		%>
		<!-- 载入页尾 -->
		<jsp:include page="../include/foot.jsp"></jsp:include>
	</body>
</html>

⌨️ 快捷键说明

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