如何让一个Servlet类处理多个业务请求
1.创建一个Servlet,将其访问设置为*.do
??? <url-pattern>*.do</url-pattern>
2.一个请求url格式:http://localhost:8080/*.do(*代表自定义请求名)
3.?Servlet获取请求路径名,根据路径名称执行相应的业务方法
?public void service(HttpServletRequest request, HttpServletResponse response)
???throws ServletException, IOException {
????? String uri = request.getRequestURI();
??? ? String path = uri.substring(uri.lastIndexOf("/"),uri.lastIndexOf("."));
???? ?response.setContentType("text/html;charset=utf-8");
???? ?PrintWriter out = response.getWriter();
????? /**根据用户提交的请求与对应的业务逻辑进行匹配判断*/
???? ?if(path.equals("/请求名")){
????????? //do.....
????? }else if(path.equals("/请求名")){
?????? ? //do.....
????? }
}