javaweb中的一些路径

174 阅读1分钟

一个项目打包之后名为app,放入到tomcat的webapps目录下,

请求:http://localhost:8080/app/hello 方法:request.getContextPath() 值:/app 方法:request.getRequestURI() 值:/app/hello 方法:request.getRequestURL() 值:http://localhost:8091/app/hello 方法:request.getServletPath() 值:/hello

将该项目打包后的名称改为ROOT, 请求:http://localhost:8080/hello 方法:request.getContextPath() 值:(空字符串) 方法:request.getRequestURI() 值:/hello 方法:request.getRequestURL() 值:http://localhost:8091/hello 方法:request.getServletPath() 值:/hello