spring 获取ServletContext对象 ,获取HttpServletRequest对象

String rootPath = ContextLoader.getCurrentWebApplicationContext().getServletContext().getRealPath("/");

private HttpServletRequest getRequest() { 
        return ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest(); 
    }

猜你喜欢

转载自blog.csdn.net/weixin_39209728/article/details/85458658