java获取HttpServletRequest 对象



import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

实现代码:

ServletRequestAttributes attr=(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();

        HttpServletRequest request =attr.getRequest();

猜你喜欢

转载自blog.csdn.net/liyongbing1122/article/details/80323939