request原理:
request功能:
代码示例:
package org.example.controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.Enumeration; @RestController public class ParamController { @RequestMapping(value = "/test1") public void test1(HttpServletRequest request) { System.out.println(request.getMethod()); //获取请求方式; System.out.println(request.getContextPath()); //获取虚拟目录 System.out.println(request.getServletPath()); //获取servlet路径 System.out.println(request.getQueryString()); //获取请求参数 System.out.println(request.getRequestURI()); //获取请求URI,部分 System.out.println(request.getRequestURL()); //获取请求URI,全部 } }
响应:
标签:请求,示例,spring,request,System,println,import,out From: https://www.cnblogs.com/xiaobaibailongma/p/17034648.html