开发者学堂课程【Servlet 入门: BaseServlet (1)】学习笔记,与课程紧密联系,让用户快速学习知识。
课程地址:https://developer.aliyun.com/learning/course/34/detail/759
BaseServlet (1)
内容介绍
一、BaseServlet
一、BaseServlet
1.我们希望在一个 Servlet 中可以有多个请求处理方法!
domain: User
dao: UserDao
sezvice: DserService
servlet: UserServlet
vo1d init (ServletConfig config)
void destory()
void sezvice (ServlecRequest, ServletResponse)
throvs IOException, ServletException{
在这里让它去调用其他方法!
要求:用户发出请求时,必须给出一个参数,来说明要调用哪一个方法
获取参数,通过参数名称来确定要调用的方法
publ1c void addUser() (
btsp:/1coahost:8080/xx/AServlet7meaddUser
package en.itcast web.servlet;
import java.io. IOException;
在这里给出多个请求处理方法
请求处理方法:除了名称以外,都与 secvice 相同!
@author cxf
publio lass AServlet extends HttpServlet {
publio void doGet (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException{
doPost (request, response);
public void doPost (HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
11 TODO Auto-generated method stub
super.doPost(req, resp);
public void addUser (HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
system. out.println("addUser()...");
public void editUse (HttpServletRequest req,HttpServletResponse reap)
throws ServletException, IOException {
system. out.println("editUser()...");
public void deleteUse (HttpSezvletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
System. out.println("deleteUser()...");