以访问的jsp为:http://localhost:8080/dmsd-itoo-exam-log-web/course/index.jsp,工程名为/dmsd-itoo-exam-log-web为例: request.getContextPath(),得到工程名:/dmsd-itoo-exam-log-web; 注意 : 是 / 加上 工程名: 右斜杠+工程名 不是 单单工程名,本质是绝对路径 ,/之前加上 localhost:8080 就可以直接在访问页面了