javaWeb:request学习
1.获得请求消息的
ServletRequest接口
HttpservletRequest接口
@WebServlet(name = "helloServlet", value = "/hello-servlet")
//http://localhost:8080/demo3_war_exploded/基础上再输入hello-servlet
执行helllo-servlet里面的doget(){}方法
2.doget(){}输入:
String method=request.getMethod();
System.out.println(method); //获取请求方式GET
String contextPath= request.getContextPath();
System.out.println(contextPath);
String servletPath= request.getServletPath();
System.out.println(servletPath);
String queryString= request.getQueryString();
System.out.println(queryString);
String requestURI= request.getRequestURI();
System.out.println(requestURI);
String protocol=request.getProtocol();
System.out.println(protocol);
3.获取请求头数据:
之后补充