@WebServlet("/admin/addScore") public class AddScoreController extends HttpServlet { private static final long serialVersionUID = 1L; public AddScoreController() { super(); // TODO Auto-generated constructor stub } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub String isbn = request.getParameter("isbn"); String courseName = request.getParameter("courseName"); String className = request.getParameter("className"); String num = request.getParameter("num"); Score score = new Score(); score.setIsbn(isbn); score.setCourseName(courseName); score.setClassName(className); score.setNum(Integer.valueOf(num)); ScoreService scoreService = new ScoreService(); scoreService.addScore(score); request.getRequestDispatcher("/admin/tecoursesUrl").forward(request, response); } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet(request, response); } }
时间: 2024-04-07 08:31:32 浏览: 93
这是一个Java Servlet,用于处理添加成绩的请求。根据请求中的参数,创建一个Score对象,设置其属性,并将其传递给ScoreService进行添加。然后,将请求重定向到"/admin/tecoursesUrl"页面。其中,doGet()方法处理HTTP GET请求,doPost()方法处理HTTP POST请求。
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![application/x-zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![-](https://img-home.csdnimg.cn/images/20241231044930.png)