package com.futureweaver.web;
import javax.servlet.; import javax.servlet.http.; import javax.servlet.annotation.*; import java.io.IOException;
@WebServlet("/login")
public class LoginServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 请求方式 System.out.println(request.getMethod());
// 请求的URI
System.out.println(request.getRequestURL());
System.out.println(request.getRequestURI());
// 重点: 获取项目路径
System.out.println(request.getContextPath());
// 重点: 获取资源路径
System.out.println(request.getServletPath());
// 协议/版本
System.out.println(request.getProtocol());
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doGet(request, response);
}
}