request.getServletContext().getContextPath()

增加项目名称是test。那么上面的结果就是/test