本文整理了Java中org.kohsuke.stapler.StaplerRequest.getOriginalRequestURI()
方法的一些代码示例,展示了StaplerRequest.getOriginalRequestURI()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StaplerRequest.getOriginalRequestURI()
方法的具体详情如下:
包路径:org.kohsuke.stapler.StaplerRequest
类名称:StaplerRequest
方法名:getOriginalRequestURI
[英]Gets the HttpServletRequest#getRequestURI()of the original request, so that you can access the value even from JSP.
[中]获取原始请求的HttpServletRequest#getRequestURI(),以便您甚至可以从JSP访问该值。
代码示例来源:origin: jenkinsci/jenkins
public Object evaluate(JellyContext context) {
try {
CURRENT_CONTEXT.set(context);
JexlContext jexlContext = new JellyJexlContext( context );
return expression.evaluate(jexlContext);
} catch (AcegiSecurityException e) {
// let the security exception pass through
throw e;
} catch (Exception e) {
StaplerRequest currentRequest = Stapler.getCurrentRequest();
LOGGER.log(Level.WARNING,"Caught exception evaluating: " + expression + " in " + (currentRequest != null ? currentRequest.getOriginalRequestURI() : "?") + ". Reason: " + e, e);
return null;
} finally {
CURRENT_CONTEXT.set(null);
}
}
代码示例来源:origin: jenkinsci/jenkins
public static RunUrl decompose(StaplerRequest req) {
List<Ancestor> ancestors = req.getAncestors();
// find the first and last Run instances
Ancestor f=null,l=null;
for (Ancestor anc : ancestors) {
if(anc.getObject() instanceof Run) {
if(f==null) f=anc;
l=anc;
}
}
if(l==null) return null; // there was no Run object
String head = f.getPrev().getUrl()+'/';
String base = l.getUrl();
String reqUri = req.getOriginalRequestURI();
// Find "rest" or URI by removing N path components.
// Not using reqUri.substring(f.getUrl().length()) to avoid mismatches due to
// url-encoding or extra slashes. Former may occur in Tomcat (despite the spec saying
// this string is not decoded, Tomcat apparently decodes this string. You see ' '
// instead of '%20', which is what the browser has sent), latter may occur in some
// proxy or URL-rewriting setups where extra slashes are inadvertently added.
String furl = f.getUrl();
int slashCount = 0;
// Count components in ancestor URL
for (int i = furl.indexOf('/'); i >= 0; i = furl.indexOf('/', i + 1)) slashCount++;
// Remove that many from request URL, ignoring extra slashes
String rest = reqUri.replaceFirst("(?:/+[^/]*){" + slashCount + "}", "");
return new RunUrl( (Run) f.getObject(), head, base, rest);
}
代码示例来源:origin: mocleiri/github-oauth-plugin
private String requestURI() {
return Stapler.getCurrentRequest().getOriginalRequestURI();
}
代码示例来源:origin: org.jvnet.hudson.plugins/violations
/**
* get the build number from a uri.
* @param req the request params
* @return the build numberr if presend, 0 ofherwise.
*/
public static int findBuildNumber(StaplerRequest req) {
String requestURI = req.getOriginalRequestURI();
String contextPath = req.getContextPath();
if (contextPath != "") {
if (!requestURI.startsWith(contextPath)) {
return 0;
}
requestURI = requestURI.substring(contextPath.length());
}
// check if starts with /job
if (!requestURI.startsWith("/job")) {
return 0;
}
String[] parts = requestURI.split("/");
// blank + job + jobname + number + rest...
if (parts.length < (BUILD_NUMBER_POS + 1)) {
return 0;
}
try {
return Integer.parseInt(parts[BUILD_NUMBER_POS]);
} catch (Exception ex) {
return 0;
}
}
}
代码示例来源:origin: org.jenkins-ci.plugins/violations
/**
* get the build number from a uri.
* @param req the request params
* @return the build number if present, 0 otherwise.
*/
public static int findBuildNumber(StaplerRequest req) {
String requestURI = req.getOriginalRequestURI();
String contextPath = req.getContextPath();
if (contextPath != "") {
if (!requestURI.startsWith(contextPath)) {
return 0;
}
requestURI = requestURI.substring(contextPath.length());
}
// check if starts with /job
if (!requestURI.startsWith("/job")) {
return 0;
}
String[] parts = requestURI.split("/");
// blank + job + jobname + number + rest...
if (parts.length < (BUILD_NUMBER_POS + 1)) {
return 0;
}
try {
return Integer.parseInt(parts[BUILD_NUMBER_POS]);
} catch (Exception ex) {
return 0;
}
}
}
代码示例来源:origin: jenkinsci/violations-plugin
/**
* get the build number from a uri.
* @param req the request params
* @return the build number if present, 0 otherwise.
*/
public static int findBuildNumber(StaplerRequest req) {
String requestURI = req.getOriginalRequestURI();
String contextPath = req.getContextPath();
if (contextPath != "") {
if (!requestURI.startsWith(contextPath)) {
return 0;
}
requestURI = requestURI.substring(contextPath.length());
}
// check if starts with /job
if (!requestURI.startsWith("/job")) {
return 0;
}
String[] parts = requestURI.split("/");
// blank + job + jobname + number + rest...
if (parts.length < (BUILD_NUMBER_POS + 1)) {
return 0;
}
try {
return Integer.parseInt(parts[BUILD_NUMBER_POS]);
} catch (Exception ex) {
return 0;
}
}
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
public Object evaluate(JellyContext context) {
try {
CURRENT_CONTEXT.set(context);
JexlContext jexlContext = new JellyJexlContext( context );
return expression.evaluate(jexlContext);
} catch (AcegiSecurityException e) {
// let the security exception pass through
throw e;
} catch (Exception e) {
StaplerRequest currentRequest = Stapler.getCurrentRequest();
LOGGER.log(Level.WARNING,"Caught exception evaluating: " + expression + " in " + (currentRequest != null ? currentRequest.getOriginalRequestURI() : "?") + ". Reason: " + e, e);
return null;
} finally {
CURRENT_CONTEXT.set(null);
}
}
代码示例来源:origin: org.eclipse.hudson.main/hudson-core
public static RunUrl decompose(StaplerRequest req) {
List<Ancestor> ancestors = req.getAncestors();
// find the first and last Run instances
Ancestor f=null,l=null;
for (Ancestor anc : ancestors) {
if(anc.getObject() instanceof Run) {
if(f==null) f=anc;
l=anc;
}
}
if(l==null) return null; // there was no Run object
String head = f.getPrev().getUrl()+'/';
String base = l.getUrl();
String reqUri = req.getOriginalRequestURI();
// Find "rest" or URI by removing N path components.
// Not using reqUri.substring(f.getUrl().length()) to avoid mismatches due to
// url-encoding or extra slashes. Former may occur in Tomcat (despite the spec saying
// this string is not decoded, Tomcat apparently decodes this string. You see ' '
// instead of '%20', which is what the browser has sent), latter may occur in some
// proxy or URL-rewriting setups where extra slashes are inadvertently added.
String furl = f.getUrl();
int slashCount = 0;
// Count components in ancestor URL
for (int i = furl.indexOf('/'); i >= 0; i = furl.indexOf('/', i + 1)) slashCount++;
// Remove that many from request URL, ignoring extra slashes
String rest = reqUri.replaceFirst("(?:/+[^/]*){" + slashCount + "}", "");
return new RunUrl( (Run) f.getObject(), head, base, rest);
}
代码示例来源:origin: org.jenkins-ci.main/jenkins-core
public static RunUrl decompose(StaplerRequest req) {
List<Ancestor> ancestors = req.getAncestors();
// find the first and last Run instances
Ancestor f=null,l=null;
for (Ancestor anc : ancestors) {
if(anc.getObject() instanceof Run) {
if(f==null) f=anc;
l=anc;
}
}
if(l==null) return null; // there was no Run object
String head = f.getPrev().getUrl()+'/';
String base = l.getUrl();
String reqUri = req.getOriginalRequestURI();
// Find "rest" or URI by removing N path components.
// Not using reqUri.substring(f.getUrl().length()) to avoid mismatches due to
// url-encoding or extra slashes. Former may occur in Tomcat (despite the spec saying
// this string is not decoded, Tomcat apparently decodes this string. You see ' '
// instead of '%20', which is what the browser has sent), latter may occur in some
// proxy or URL-rewriting setups where extra slashes are inadvertently added.
String furl = f.getUrl();
int slashCount = 0;
// Count components in ancestor URL
for (int i = furl.indexOf('/'); i >= 0; i = furl.indexOf('/', i + 1)) slashCount++;
// Remove that many from request URL, ignoring extra slashes
String rest = reqUri.replaceFirst("(?:/+[^/]*){" + slashCount + "}", "");
return new RunUrl( (Run) f.getObject(), head, base, rest);
}
代码示例来源:origin: org.jvnet.hudson.main/hudson-core
public static RunUrl decompose(StaplerRequest req) {
List<Ancestor> ancestors = req.getAncestors();
// find the first and last Run instances
Ancestor f=null,l=null;
for (Ancestor anc : ancestors) {
if(anc.getObject() instanceof Run) {
if(f==null) f=anc;
l=anc;
}
}
if(l==null) return null; // there was no Run object
String head = f.getPrev().getUrl()+'/';
String base = l.getUrl();
String reqUri = req.getOriginalRequestURI();
// Find "rest" or URI by removing N path components.
// Not using reqUri.substring(f.getUrl().length()) to avoid mismatches due to
// url-encoding or extra slashes. Former may occur in Tomcat (despite the spec saying
// this string is not decoded, Tomcat apparently decodes this string. You see ' '
// instead of '%20', which is what the browser has sent), latter may occur in some
// proxy or URL-rewriting setups where extra slashes are inadvertently added.
String furl = f.getUrl();
int slashCount = 0;
// Count components in ancestor URL
for (int i = furl.indexOf('/'); i >= 0; i = furl.indexOf('/', i + 1)) slashCount++;
// Remove that many from request URL, ignoring extra slashes
String rest = reqUri.replaceFirst("(?:/+[^/]*){" + slashCount + "}", "");
return new RunUrl( (Run) f.getObject(), head, base, rest);
}
代码示例来源:origin: hudson/hudson-2.x
public static RunUrl decompose(StaplerRequest req) {
List<Ancestor> ancestors = req.getAncestors();
// find the first and last Run instances
Ancestor f=null,l=null;
for (Ancestor anc : ancestors) {
if(anc.getObject() instanceof Run) {
if(f==null) f=anc;
l=anc;
}
}
if(l==null) return null; // there was no Run object
String head = f.getPrev().getUrl()+'/';
String base = l.getUrl();
String reqUri = req.getOriginalRequestURI();
// Find "rest" or URI by removing N path components.
// Not using reqUri.substring(f.getUrl().length()) to avoid mismatches due to
// url-encoding or extra slashes. Former may occur in Tomcat (despite the spec saying
// this string is not decoded, Tomcat apparently decodes this string. You see ' '
// instead of '%20', which is what the browser has sent), latter may occur in some
// proxy or URL-rewriting setups where extra slashes are inadvertently added.
String furl = f.getUrl();
int slashCount = 0;
// Count components in ancestor URL
for (int i = furl.indexOf('/'); i >= 0; i = furl.indexOf('/', i + 1)) slashCount++;
// Remove that many from request URL, ignoring extra slashes
String rest = reqUri.replaceFirst("(?:/+[^/]*){" + slashCount + "}", "");
return new RunUrl( (Run) f.getObject(), head, base, rest);
}
代码示例来源:origin: org.eclipse.hudson/hudson-core
String base = getAncestorUrl(req, l);
String reqUri = req.getOriginalRequestURI();
内容来源于网络,如有侵权,请联系作者删除!