package Http0824;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/demo/HttpServlet")
public class HttpServlet extends javax.servlet.http.HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
System.out.println("getMethod: " +request.getMethod());
System.out.println("getContextPath: " +request.getContextPath());
System.out.println("getServletPath: " + request.getServletPath());
System.out.println("getRequestsURI: " + request.getRequestURI());
System.out.println("getRequestURL:"+ request.getRequestURL());
System.out.println("getQueryString:" + request.getQueryString());
System.out.println("getRemoteAddr: " + request.getRemoteAddr());
}
}
http协议的reqeust方法getContextPath
Servlet核心技术:GET/POST请求处理与环境变量详解
最新推荐文章于 2024-01-18 14:19:15 发布
本文详细介绍了如何在HttpServlet中处理GET和POST请求,展示了HttpServletRequest的方法、路径、URI、URL、查询字符串等属性,并讲解了获取客户端地址的方法。
1732

被折叠的 条评论
为什么被折叠?



