jsp+servletç»å½é¡µé¢è®¾è®¡+mysqlæ°æ®åºé¾æ¥
ç®åjspç»å½çè¨é¡µé¢+æ°æ®åºé¾æ¥æºä»£ç
宿´æºä»£ç ä¸è½½å°åï¼https://download.****.net/download/weixin_43960044/11057955
ç»å½é¡µé¢ï¼
ç»å½ç颿ºä»£ç ï¼
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!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=ISO-8859-1">
<title>Insert title here</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<%
Boolean yanzheng = true;
if(!yanzheng){
HttpSession session1 = request.getSession();
yanzheng = (Boolean)session.getAttribute("yanzheng");
System.out.println(yanzheng);
}
/*
HttpSession session1 = request.getSession();
yanzheng = (Boolean)session.getAttribute("yanzheng");
System.out.println(yanzheng);
*/
%>
<h1>Gosså¾®å</h1>
<div class="element">
<div class="element-left">
<div class="profile">
<div class="profile-follow">
<ul>
<li style="color: white; font-size: 26px; margin-top: -15px;">ç¨æ·ç»å½</li>
</ul>
</div>
<div class="login-top">
<form method="post" action="land">
ç¨æ·åï¼<input type="text" name="username"><br>
å¯ç ï¼<input type="password" name="password">
<%
if(!yanzheng){
out.print("<div><li>è´¦å·æè
å¯ç é误ï¼</li></div>");
}
%>
<div class="login-bottom">
<ul>
</ul>
<ul>
<li><a href="#">å¿è®°å¯ç </a></li>
<li>
<input type="submit" value="ç»å½">
<a href="regist.html"><input type="button" value="注å"></a>
</li>
</ul>
</div>
</form>
<div class="clear"></div>
</div>
</div>
</div>
</div>
</body>
</html>
çè¨çé¢ï¼
çè¨ç颿ºä»£ç ï¼
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ page import="java.sql.ResultSet, java.sql.SQLException, Connector.DataBaseOperate" %>
<!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>My Widget</title>
<link rel="stylesheet" href="./liuyan_files/style.css" type="text/css">
</head>
<%
DataBaseOperate da = new DataBaseOperate();
ResultSet rs = da.query("SELECT * FROM contenttable order by data desc");
System.out.println("æ§è¡");
%>
<body>
<div class="element">
<div class="element-left">
<div class="profile">
<div class="profile-top">
<div class="profile-text">
<div class="profile-img"><img src="./liuyan_files/b1.jpg" alt=""></div>
<div class="profile-text1">
<h4><%out.print(session.getAttribute("username1")); %></h4>
<a href="http://localhost:8080/webshiyan1/index.jsp"><i></i>注é</a>
</div>
<div class="clear"></div>
</div>
<div class="login-top">
<form method="post" action="liuyan">
å享æ°é²äº...<br>
<textarea cols="50" rows="4" name="content"></textarea>
<br>
<button type="submit">éåº</button>
</form>
<table style="text-align: left; width: 460px; height: 88px;" border="0" cellpadding="2"
cellspacing="2">
<tbody>
<tr>
<td style="vertical-align:top;">
<%while(rs.next()){ %>
<%out.print("<tr><td>"); %>
<%out.print(rs.getString(4)); %>
<%out.print(rs.getString(1)+"<br>"); %>
<%out.print(rs.getString(2)); %>
<%String lianjie= "http://localhost:8080/webshiyan1/deleteliuyan?message=" + rs.getString(3); %>
<%out.print("<a href=" + lianjie + ">å é¤</a>"); %>
<%out.print("<hr>"); %>
<%out.print("</tr></td>"); %>
<%} %>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
mysqlæ°æ®åºï¼
/*
Navicat MySQL Data Transfer
Source Server : localhost
Source Server Version : 50027
Source Host : localhost:3306
Source Database : liuyan
Target Server Type : MYSQL
Target Server Version : 50027
File Encoding : 65001
Date: 2019-03-25 14:35:33
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for `contenttable`
-- ----------------------------
DROP TABLE IF EXISTS `contenttable`;
CREATE TABLE `contenttable` (
`data` char(100) default NULL,
`content` char(100) default NULL,
`id` int(20) NOT NULL auto_increment,
`username` char(100) default NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of contenttable
-- ----------------------------
INSERT INTO `contenttable` VALUES ('2019-03-16 18:13:20', 'ä½ å¥½åï¼', '3', 'test');
INSERT INTO `contenttable` VALUES ('2019-03-16 18:13:34', 'è¿éæ¯çè¨ç¨åºï¼', '4', 'test');
-- ----------------------------
-- Table structure for `user`
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`username` char(20) NOT NULL,
`password` char(30) NOT NULL,
`email` char(30) NOT NULL,
PRIMARY KEY (`username`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO `user` VALUES ('test', '123', '[email protected]');