整体框架发生了非常奇怪的问题!

整体框架发生了非常奇怪的问题!

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

2回答
好帮手慕阿莹 2019-03-17 11:36:46

同学不能再转发到server这个jsp页面了,可以转发到添加图书的Servlet,然后添加的Servlet转发到添加图书的jsp上添加图书,如果添加完了分类不想添加,同学就不用转发到server.jsp中了。只把分类存LibDaoImpl 中就可以了。因为同学要把转发的页面让其在“main”这个模块展示,恰恰,同学转发的又是一个整体的jsp,就会出现这个情况了

如果我的回答解决了你的问题,请采纳,祝学习愉快.


  • 但是我看视频添加完一个类以后就是回到server这个界面呀(main部分什么都没有),请问要如何实现它?
    2019-03-17 20:36:47
  • 那同学就把转发的语句去掉试试,不用进行跳转,是可以返回到server这个界面的。 祝学习愉快。
    2019-03-18 14:41:14
  • 姐姐,转发和跳转有什么区别,不太理解…
    2019-03-18 16:45:34
提问者 爱动脑筋的小伙伴 2019-03-16 10:33:11
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String path=request.getContextPath();
	String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>图书后台管理系统</title>
</head>
<frameset rows="20%,*">
	<frame src="<%=basePath %>/top.jsp"></frame>
	<frameset cols="10%,*">
		<frame src="<%=basePath %>/left.jsp"></frame>
		<frame name="main"></frame>
	</frameset>
</frameset>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String path=request.getContextPath();
	String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<p><a href="<%=basePath%>/category.jsp" target="main">分类添加</a></p>
	<p><a href="<%=basePath%>/ToAddBookServlet" target="main">图书添加</a></p>
	<p><a href="<%=basePath%>/SelectBookServlet" target="main">图书查询</a></p>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String path=request.getContextPath();
	String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
	<center>
		<h1>图书分类添加</h1>
		<form action="<%=basePath%>/CategoryServlet" method="post">
			<table width="400px" cellspacing="0px" cellpadding="0px" border="1px">
				<tr>
					<td>分类ID</td>
					<td><input type="text" name="id"></td>
				</tr>
				<tr>
					<td>名&nbsp;字</td>
					<td><input type="text" name="categoryName"></td>
				</tr>
				<tr>
					<td>描&nbsp;述</td>
					<td><input type="text" name="description"></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>
package com.imooc.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.imooc.myclass.LibDaoImpl;

/**
 * Servlet implementation class CategoryServlet
 */
@WebServlet("/CategoryServlet")
public class CategoryServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public CategoryServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		LibDaoImpl ldi=new LibDaoImpl();
		String id=request.getParameter("id");
		String categoryName=request.getParameter("categoryName");
		String description=request.getParameter("description");
		ldi.addBookCategory(id, categoryName, description);
		request.getRequestDispatcher("/server.jsp").forward(request, response);
	}

}


问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
从网页搭建入门Java Web2018版
  • 参与学习           人
  • 提交作业       1088    份
  • 解答问题       10204    个

如果你有Java语言基础,又想以后从事Java Web开发,那么本路径是你的不二选择!本路径从网页搭建开始入手,通过大量案例来学习Java Web基础。定能助你完成Java Web小白的蜕变!

了解课程
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师