关于分类ID问题
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <html> <head> <meta charset="UTF-8"> <title>科室列表</title> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/index.css"> <link rel="stylesheet" href="${pageContext.request.contextPath}/css/bootstrap.min.css"> </head> <body> <header> <div class="container"> <nav> <a href="internal.do?id=${1}" >内科</a> </nav> <nav> <a href="surgery.do?id=${3}" >外科</a> </nav> <nav> <a href="list.do" >分类</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> <c:forEach items="${LIST}" var="cat"> <tr> <td>${cat.name}</td> <td>${cat.id}</td> <td>${cat.createTime}</td> <td>${cat.updateTime}</td> <td> <a href="toEdit.do?id=${cat.id}">修改</a> <a href="remove.do?id=${cat.id}">删除</a> </td> </tr> </c:forEach> </tbody> </table> </div> </section> <section class="page"> <div class="container"> <div id="fatie"> <a href="toAdd.do"><button>新建</button></a> </div> </div> </section> <footer> copy@慕课网 </footer> </body> </html>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <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="internal.do" >内科</a> </nav> <nav> <a href="surgery.do" >外科</a> </nav> <nav> <a href="list.do" >分类</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> <c:forEach items="${LIST}" var="dep"> <tr> <td>${dep.name}</td> <td>${dep.categoryId}</td> <td>${dep.createTime}</td> <td>${dep.updateTime}</td> <td> <a href="">修改</a> <a href="">删除</a> </td> </tr> </c:forEach> </tbody> </table> </div> </section> <section class="page"> <div class="container"> <div id="fatie"> <a href="toAdd_i.do"><button>新建</button></a> </div> </div> </section> <footer> copy@慕课网 </footer> </body> </html>
package com.imooc.hp.controller; import com.imooc.hp.entity.Category; import com.imooc.hp.entity.Department; import com.imooc.hp.service.CategoryService; import com.imooc.hp.service.DepartmentService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.List; @Controller("categoryController") public class CategoryController { @Autowired private CategoryService categoryService; @Autowired private DepartmentService departmentService; //分类 public void list(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { List<Category> list=categoryService.getAll(); request.setAttribute("LIST",list); request.getRequestDispatcher("../category.jsp").forward(request,response); } public void toAdd(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.getRequestDispatcher("../add_c.jsp").forward(request,response); } public void add(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String name=request.getParameter("name"); Category category=new Category(); category.setName(name); categoryService.add(category); response.sendRedirect("list.do"); } public void toEdit(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int id=Integer.parseInt(request.getParameter("id")); Category category=categoryService.get(id); request.setAttribute("OBJ",category); request.getRequestDispatcher("../edit.jsp").forward(request,response); } public void edit(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int id=Integer.parseInt(request.getParameter("id")); String name=request.getParameter("name"); Category category=new Category(); category.setId(id); category.setName(name); categoryService.edit(category); response.sendRedirect("list.do"); } public void remove(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int id=Integer.parseInt(request.getParameter("id")); categoryService.remove(id); response.sendRedirect("list.do"); } //内科 public void internal(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int categoryId=Integer.parseInt(request.getParameter("id")); List<Department> list=departmentService.getAll(categoryId); request.setAttribute("LIST",list); request.getRequestDispatcher("../category_n.jsp").forward(request,response); } public void toAdd_i(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { List<Category> cat=categoryService.getAll(); request.setAttribute("CAT",cat); request.getRequestDispatcher("../add_i.jsp").forward(request,response); } public void add_i(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String name=request.getParameter("name"); int categoryId=Integer.parseInt(request.getParameter("categoryId")); Department department=new Department(); department.setName(name); department.setCategoryId(categoryId); departmentService.add(department); response.sendRedirect("internal.do"); } //外科 public void surgery(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int categoryId=Integer.parseInt(request.getParameter("categoryId")); List<Department> list=departmentService.getAll(categoryId); request.setAttribute("LIST",list); request.getRequestDispatcher("../category_w.jsp").forward(request,response); } public void toAdd_s(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.getRequestDispatcher("../add_s.jsp").forward(request,response); } public void add_s(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String name=request.getParameter("name"); Department department=new Department(); department.setName(name); departmentService.add(department); response.sendRedirect("surgery.do"); } }
当我进入内科列表时就如下显示,不知道怎么改
22
收起
正在回答 回答被采纳积分+1
3回答
4. SSM到Spring Boot入门与综合实战
- 参与学习 人
- 提交作业 323 份
- 解答问题 8263 个
本阶段将带你学习主流框架SSM,以及SpringBoot ,打通成为Java工程师的最后一公里!
了解课程
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星