WebLogic request.getContextPath() 为 null 问题

当使用 Weblogic 作为中间件,并且 Web 项目部署方式为 war 包部署时,jsp 页面request.getContextPath() 将返回 null,此时加入以下代码设置 webRoot 即可:

1
2
3
4
5
String webRoot = request.getSession().getServletContext().getRealPath("/");
if(webRoot == null){
webRoot = this.getClass().getClassLoader().getResource("/").getPath();
webRoot = webRoot.substring(0,webRoot.indexOf("WEB-INF"));
}

WebLogic request.getContextPath() 为 null 问题
https://mritd.com/2016/04/22/weblogic-request-getcontextpath-null/
作者
Kovacs
发布于
2016年4月22日
许可协议