package com.itheima.b_login;import java.io.IOException;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import sun.security.util.Password;/** * Servlet implementation class UserServlet */public class UserServlet extends HttpServlet { private static final long serialVersionUID = 1L; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { String username = request.getParameter("username"); String password = request.getParameter("password"); User user = new User(); user.setUsername(username); user.setUsername(password); UserService userService = new UserService(); User existUser = userService.login(user); } catch (Exception e) { e.printStackTrace(); } } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); }}请问代码中的异常已经抛出了 为神恶魔还要try catch;它俩有什么不同,以及什么时候用, 什么时候一起用?
添加回答
举报
0/150
提交
取消