1、getContextPath:站点名[/context](Web应用的入口点名字)
2、getServletPath:servlet类的对应映射路径[/resource]
3、getRequestURI:uri地址 = [/context] + [/resource]
4、getRequestURL:protocol://IP adderss:[port][/context][/resource][/?query string]
5、代码显例如下:
package com.tiger.path.action;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
/**
* 结论:在jsp的标签中写入下面一段代码,之后所有链接都可以使用绝对路劲,像这样
* ContextPath = ").append(request.getContextPath()).append("
").
append(" ServeltPath = ").append(request.getServletPath()).append("
").
append(" RquestURI = ").append(request.getRequestURI()).append("
").
append(" RquestURL = ").append(request.getRequestURL()).append("
").
append(" Scheme = ").append(request.getScheme()).append("
").
append(" ServerName = ").append(request.getServerName()).append("
").
append(" ServerPort = ").append(String.valueOf(request.getServerPort())+"");
}
}