正在回答
你好同学,建议你将server.jsp页面改为下图样式,经测试,下图代码是没有问题的。你可以将我的代码粘贴到你的ide中进行测试,如果还有问题可以继续提问。祝学习愉快~
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>图书后台管理系统</title> </head> <frameset rows="20%,*"> <frame src="./top.jsp"></frame> <frameset cols="10%,*"> <frame src="./left.jsp"></frame> <frame name="main"></frame> </frameset> </frameset> </html>
如下图所示,建议同学将body标签删除试一试,祝学习愉快~
<%--server.jsp--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>图书后台管理系统</title>
</head>
<frameset rows="20%,80%">
<frame src="top.jsp"></frame>
<frameset cols="15%,80%">
<frame src="left.jsp"></frame>
<frame name="main"></frame>
</frameset>
</frameset>
<body>
</body>
</html>
<%--left.jsp--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String basePath = request.getScheme() + "://" + request.getServerName() +
":" + request.getServerPort() + request.getContextPath();
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>图书后台管理</title>
</head>
<body>
<p>
<a href="<%=basePath%>/catgory.jsp" target="main">分类添加</a>
</p>
<p>
<a href="<%=basePath%>/addBook.jsp" target="main">图书添加</a>
</p>
<p>
<a href="<%=basePath%>/showBooks.jsp" target="main">图书查询</a>
</p>
</body>
</html>
<%--addbook.jsp--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.List" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String basePath = request.getScheme() + "://" + request.getServerName() +
":" + request.getServerPort() + request.getContextPath();
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>图书添加</title>
</head>
<body>
<center>
<h1>图书添加</h1>
<form action="<%=basePath%>/AddBookServlet" method="post">
<table width="400px" cellspacing="0px" cellpadding="0px" border="1px">
<tr>
<td>图书ID</td>
<td><input type="text" name="id" placeholder="请输入数字" pattern="\d+" required="required"></td>
</tr>
<tr>
<td>图书名</td>
<td><input type="text" name="bookName"></td>
</tr>
<tr>
<td>图书分类</td>
<%--添加图书分类--%>
<%
List<Map<String, Object>> bookclassfyDb = (List<Map<String, Object>>)session.getAttribute("bookclassfyDb");
%>
<td>
<select name="catgoryName">
<c:forEach var="map" items="${bookclassfyDb}">
<option value="${map.catgoryName}">${map.catgoryName}</option>
</c:forEach>
</select>
</td>
</tr>
<tr>
<td>价格</td>
<td><input type="text" name="price" placeholder="请输入价格" ></td>
</tr>
<tr>
<td>描述</td>
<td><input type="text" name="description" placeholder="请输入描述信息"></td>
</tr>
<tr>
<td colspan="2" style="text-align:center">
<input type="submit" value="添加">
<input type="reset" value="重置">
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
<%--index.jsp--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String basePath = request.getScheme() + "://" + request.getServerName() +
":" + request.getServerPort() + request.getContextPath();
%>
<%
String flag = request.getParameter("flag");
%>
<!DOCTYPE html>
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>图书后台管理登录界面</title>
<script type="text/javascript">
var flag = '<%=flag%>';
if("1" == flag){
alert("您尚未登录,请先登录!")
}
</script>
</head>
<body>
<center>
<h1>登录 | <a href="<%=basePath%>/regist.jsp">注册</a></h1>
<form action="<%=basePath%>/LoginServlet" method="post">
<table width="350px" cellspacing="0px" cellpadding="0px" border="1px">
<tr>
<td>用户名</td>
<td><input type="text" name="username" required="required" placeholder="用户名为3-12位字母数字或下划线组合" ></td>
</tr>
<tr>
<td>密 码</td>
<td><input type="password" name="password" required="required" placeholder="长度为6-12位的纯数字" ></td>
</tr>
<tr>
<td colspan="2" style="text-align:center">
<input type="submit" value="登录">
<input type="reset" value="取消">
</td>
</tr>
</table>
</form>
</center>
</body>
</html>
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
version="4.0">
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>RegisterServlet</servlet-name>
<servlet-class>com.leo.servlet.RegisterServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RegisterServlet</servlet-name>
<url-pattern>/RegisterServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>LoginServlet</servlet-name>
<servlet-class>com.leo.servlet.LoginServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>LoginServlet</servlet-name>
<url-pattern>/LoginServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>CatgoryServlet</servlet-name>
<servlet-class>com.leo.servlet.CatgoryServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CatgoryServlet</servlet-name>
<url-pattern>/CatgoryServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>AddBookServlet</servlet-name>
<servlet-class>com.leo.servlet.AddBookServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AddBookServlet</servlet-name>
<url-pattern>/AddBookServlet</url-pattern>
</servlet-mapping>
过滤器
<filter>
<filter-name>CharsetEncodingFilter</filter-name>
<filter-class>com.leo.filter.CharsetEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharsetEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>AuthFilter</filter-name>
<filter-class>com.leo.filter.AuthFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>AuthFilter</filter-name>
<url-pattern>/server.jsp</url-pattern>
</filter-mapping>
</web-app>
可以的同学,建议你将server.jsp页面和frame框架所包含的页面粘贴到回答中,注意不要粘贴到回复中哦,否则会失去代码格式的,祝学习愉快~
- 参与学习 人
- 提交作业 1088 份
- 解答问题 10205 个
如果你有Java语言基础,又想以后从事Java Web开发,那么本路径是你的不二选择!本路径从网页搭建开始入手,通过大量案例来学习Java Web基础。定能助你完成Java Web小白的蜕变!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星