您的位置:首页 > 编程语言 > Java开发

Spring MVC中得到Web应用的根路径

2018-01-26 17:20 393 查看
import org.springframework.web.context.ContextLoader;

import javax.servlet.ServletContext;

/**
* Created by Gong_Yi on 2018/1/26.
*/
public class G {
String webRootUrl = "/";

ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
String webRootPath = servletContext.getRealPath(webRootUrl);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: