你刚刚启动,当然没有request
但是启动的时候会有ServletContext和ApplicationContext
比如你要获得项目路径,可以写如下代码
projectURL = getServletContext().getResource("/").getPath();
但是启动的时候会有ServletContext和ApplicationContext
比如你要获得项目路径,可以写如下代码
projectURL = getServletContext().getResource("/").getPath();
通过projectURL = getServletContext().getResource("/").getPath(); 方法获得的参数并不能直接使用,还要进行字符串处理才能获得contextpath
有没有直接一点的方法呢?