Servlet
@WebServlet("/test")
运行后的路径地址为:http://localhost/web_0929_war_exploded/test
根目录
req.getServletPath();
输出:/test
内容所在路径:/+项目文件夹名称
req.getContextPath();
输出:/web_0929_war_exploded
内容所在路径/项目根目录
req.getRequestURI();
输出:/web_0929_war_exploded/test
绝对路径
req.getRequestURL();
输出:http://localhost/web_0929_war_exploded/test
协议名称
req.getScheme();
输出:http
服务名或称域名
req.getServerName();
输出:localhost
服务端的端口号
req.getServerPort();
输出:80