获取web项目中的webroot目录路径

时间:2014-06-18 09:14:10   收藏:0   阅读:233

备忘,一段代码:

@Override
    public void init(FilterConfig arg0) throws ServletException {
        // TODO Auto-generated method stub
        logger.info("======begin web context====");
        ServletContext context=arg0.getServletContext();
        String webroot=context.getContextPath()+"/WebContent/";
        context.setAttribute("webroot", webroot);
        logger.info("webroot:"+webroot);
        
    }

在过滤器中获取的servletcontext。

获取web项目中的webroot目录路径,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!