public class ServletUtil extends Object
| 构造器和说明 |
|---|
ServletUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
getBaseURL(javax.servlet.http.HttpServletRequest request)
取得request请求的基准URL。
|
static String |
getResourcePath(javax.servlet.http.HttpServletRequest request)
取得request所请求的资源路径。
|
static String |
getServletBaseURL(javax.servlet.http.HttpServletRequest request)
取得request请求的基准URL。
|
static String |
getServletResourcePath(javax.servlet.http.HttpServletRequest request)
取得request所请求的资源路径。
|
static boolean |
isPrefixServletMapping(javax.servlet.http.HttpServletRequest request)
判断servlet是否为前缀映射。
|
static String |
normalizeURI(String uri)
规格化URI。
|
static boolean |
startsWithPath(String path,
String fullpath)
判断path是否为fullpath的前缀,匹配到“/”边界。
|
public static boolean isPrefixServletMapping(javax.servlet.http.HttpServletRequest request)
Servlet mapping有两种匹配方式:前缀匹配和后缀匹配。
public static String getResourcePath(javax.servlet.http.HttpServletRequest request)
资源路径为getServletPath() + getPathInfo()。
注意,ResourcePath以"/"开始,如果无内容,则返回空字符串
""。
public static String getBaseURL(javax.servlet.http.HttpServletRequest request)
基准URL等同于SERVER/contextPath。
基准URL总是不以"/"结尾。
以下等式总是成立:fullURL = baseURL + resourcePath。
public static String getServletResourcePath(javax.servlet.http.HttpServletRequest request)
getPathInfo()。例如映射
/turbine/*:/turbine/xx/yy的resource path为
/xx/yy。getServletPath()。例如映射
*.do:/xx/yy.do的resource path为
/xx/yy.do。
注意,ResourcePath以"/"开始,如果无内容,则返回空字符串
""。
本方法适用于servlet-mapping对应的URL。
public static String getServletBaseURL(javax.servlet.http.HttpServletRequest request)
SERVER/contextPath/servletPath。例如映射
/turbine/*:http://localhost/myapp/turbine/xx/yy
的baseURL为 http://localhost/myapp/turbine。SERVER/contextPath。例如映射
*.do:http://localhost/myapp/xx/yy.do的baseURL为
http://localhost/myapp。
基准URL总是不以"/"结尾。
以下等式总是成立:fullURL = servletBaseURL + servletResourcePath。
本方法适用于servlet-mapping对应的URL。
Copyright © 2006-2013 开源组织. All Rights Reserved.