报错的相关代码

报错的相关代码

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="f"  uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="h"  uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title>图书后台管理</title>
        <link rel="stylesheet" href="css/index.css">
        <link rel="stylesheet" href="css/bootstrap.min.css">
 
    </head>

    <body>
       <header>
            <div class="container">
                    <nav>
                            <a href="bookList.jsp" >图书信息管理</a>
                    </nav>
                    <nav>
                            <a href="categoryList.jsp" >分类管理</a>
                    </nav>
                  
            </div>
        </header>
        <section class="banner">
            <div class="container">
                <div>
                    <h1>图书管理系统</h1>
                    <p>图书分类管理</p>
                </div>
            </div>
        </section>
        <section class="main">
            <div class="container">
                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>分类编号</th>
                        <th>分类名称</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                      
                            <f:if test="${!empty cList}">
                             <f:forEach items="${cList}" var="c" varStatus="idx">
                            <tr>
                                <td>${idx.index+1}</td>
                                <td>${c.CatId}</td>
                                <td>${c.Catname}</td>
                                <td><a href="/AddCategory?cId=${c.CatId}">删除</a></td>
                                <!--在循环显示数据时,此处的ca0001可以用EL表达式进行替换-->

                            </tr>
                             </f:forEach>
                            </f:if>
                           
                      
                      
                    </tbody>
                </table>
            </div>
        </section>
        <section class="page">
            <div class="container">
                <div id="fatie">
                    <a href="addCategory.jsp"><button>新建</button></a>
                </div>
            </div>
        </section>
        <footer>
            copy@慕课网
        </footer>
        <script type="text/javascript">
      
        </script>

    </body>
</html>

package com.imooc.servlet;

import java.io.IOException;
import java.util.List;

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.reader.Category;
import com.imooc.reader.CategoryServicList;

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

 /**
  * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
  */
 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  // TODO Auto-generated method stub
 HttpServletRequest hRequest=(HttpServletRequest) request;
 HttpServletResponse hResponse=(HttpServletResponse) response;
  String categoryId= hRequest.getParameter("categoryId");
  String categoryName=hRequest.getParameter("categoryName");
 String  cId=hRequest.getParameter("cId");
 CategoryServicList  categoryServicList=new CategoryServicList();
 if (categoryId!=null&&categoryName!=null) {

  categoryServicList.addCatgory(categoryId, categoryName);
   List<Category> cList= categoryServicList.getCategorydb();
  System.out.println(cList.size());
   request.getSession().setAttribute("cList", cList);
   request.getRequestDispatcher("/categoryList.jsp").forward(request, response);
  
 }
 if (cId!=null) {
  categoryServicList.deleteCatgory(categoryId);
  List<Category> cList= categoryServicList.getCategorydb();
   request.getSession().setAttribute("cList", cList);
  request.getRequestDispatcher("/categoryList.jsp").forward(request, response);
 }
 
  
        
 
 }

 /**
  * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
  */
 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  // TODO Auto-generated method stub
  doGet(request, response);
 }

}


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

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

2回答
好帮手慕柯南 2019-06-04 16:06:23

同学的代码在老师这里没有报错呢,同学那里是不是报新的错误了。如果是建议同学贴一下报错信息呢。以后报错也要记得贴报错的信息哦

http://img1.sycdn.imooc.com//climg/5cf626420001091e03170063.jpg

祝学习愉快~

  • 提问者 慕先生4377301 #1
    全部代码已经,提交了,麻烦老师在测试一下
    2019-06-04 16:07:40
  • 好帮手慕柯南 回复 提问者 慕先生4377301 #2
    同学老师在 http://class.imooc.com/course/qadetail/122821下面回答你了
    2019-06-04 16:25:06
好帮手慕柯南 2019-06-04 14:54:43

同学你好!经测试同学的页面是可以正常运行的

http://img1.sycdn.imooc.com//climg/5cf615770001fbf106870270.jpg

同学应该缺少了以下两个包,同学添加测试一下

http://img1.sycdn.imooc.com//climg/5cf6158f0001865f03410090.jpg

如果我的回答解决了你的疑惑,请采纳,祝学习愉快~

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

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

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

0 星
请稍等 ...
意见反馈 帮助中心 APP下载
官方微信

在线咨询

领取优惠

免费试听

领取大纲

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