本文整理匯總了Java中javax.servlet.http.HttpServletRequest.getRequestURL方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpServletRequest.getRequestURL方法的具體用法?Java HttpServletRequest.getRequestURL怎麽用?Java HttpServletRequest.getRequestURL使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.servlet.http.HttpServletRequest
的用法示例。
在下文中一共展示了HttpServletRequest.getRequestURL方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: passObj
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@RequestMapping(value = "/obj", produces = "application/json;charset=UTF-8")//⑦
@ResponseBody // ⑧
public String passObj(DemoObj obj, HttpServletRequest request) {
return "url:" + request.getRequestURL()
+ " can access, obj id: " + obj.getId()+" obj name:" + obj.getName();
}
示例2: doPost
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
PrintWriter writer = response.getWriter();
Map<?, ?> parameterMap = request.getParameterMap();
// store the parameters
String sessionId = request.getSession().getId();
ParameterStorage.addSessionParams(sessionId, parameterMap);
ParameterHandler.addParametersToWriterInput(writer, parameterMap);
StringBuffer requestURL = request.getRequestURL();
int pos = requestURL.lastIndexOf("/");
String redirectURL = requestURL.substring(0, pos + 1)
+ "PSPMockService?sessionId=" + sessionId;
redirectURL = URLEncoder.encode(redirectURL, "UTF-8");
writer.printf("%s=%s", "FRONTEND.REDIRECT_URL", redirectURL);
}
示例3: getParameterWithOutCode
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/**
* 移除url中的code、username參數
* @param request
* @return
*/
public static String getParameterWithOutCode(HttpServletRequest request) {
StringBuffer backUrl = request.getRequestURL();
String params = "";
Map<String, String[]> parameterMap = request.getParameterMap();
for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
if (!entry.getKey().equals("upms_code") && !entry.getKey().equals("upms_username")) {
if (params.equals("")) {
params = entry.getKey() + "=" + entry.getValue()[0];
} else {
params += "&" + entry.getKey() + "=" + entry.getValue()[0];
}
}
}
if (!StringUtils.isBlank(params)) {
backUrl = backUrl.append("?").append(params);
}
return backUrl.toString();
}
示例4: onAccessDenied
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@Override
protected boolean onAccessDenied(ServletRequest request, ServletResponse response) throws Exception {
StringBuffer sso_server_url = new StringBuffer(PropertiesFileUtil.getInstance("lambo-upms-client").get("lambo.upms.sso.server.url"));
// server需要登錄
String upmsType = PropertiesFileUtil.getInstance("lambo-upms-client").get("lambo.upms.type");
if ("server".equals(upmsType)) {
WebUtils.toHttp(response).sendRedirect(sso_server_url.append("/sso/login").toString());
return false;
}
sso_server_url.append("/sso/index").append("?").append("appid").append("=").append(PropertiesFileUtil.getInstance("lambo-upms-client").get("lambo.upms.appID"));
// 回跳地址
HttpServletRequest httpServletRequest = WebUtils.toHttp(request);
StringBuffer backurl = httpServletRequest.getRequestURL();
String queryString = httpServletRequest.getQueryString();
if (StringUtils.isNotBlank(queryString)) {
backurl.append("?").append(queryString);
}
sso_server_url.append("&").append("backurl").append("=").append(URLEncoder.encode(backurl.toString(), "utf-8"));
WebUtils.toHttp(response).sendRedirect(sso_server_url.toString());
return false;
}
示例5: handle404Error
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@ExceptionHandler(UnknownResourceException.class)
@ResponseStatus(value = HttpStatus.NOT_FOUND)
@ResponseBody
public Result handle404Error(HttpServletRequest req) {
String url = req.getMethod() + " " + req.getRequestURL() + "?" + req.getQueryString();
logger.debug("找不到url資源 {}", url);
ResultEnum notFound = ResultEnum.NOT_FOUND;
return ResultUtils.error(notFound.getCode(), notFound.getMessage(), url);
}
示例6: getInfo
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
public static String getInfo(@NonNull Invocation inv) {
HttpServletRequest request = inv.getRequest();
return "requestURI:" + request.getRequestURI()
+ ", resourceId:" + inv.getResourceId()
+ ", queryString:" + request.getQueryString()
+ ", requestURL:" + request.getRequestURL()
+ ", parameterMap:" + request.getParameterMap()
+ ", requestPath:" + inv.getRequestPath();
}
示例7: handle400Error
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@ExceptionHandler(value = {IllegalArgumentException.class,
BindException.class, // controller中參數綁定bean時異常,如數據類型不匹配等
MissingServletRequestParameterException.class,
MethodArgumentTypeMismatchException.class,
HttpRequestMethodNotSupportedException.class})
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
@ResponseBody
public Result handle400Error(HttpServletRequest req, Exception e) {
String url = req.getMethod() + " " + req.getRequestURL() + "?" + req.getQueryString();
logger.debug("不合法的url請求: {}", url);
ResultEnum badRequest = ResultEnum.BAD_REQUEST;
return ResultUtils.error(badRequest.getCode(), badRequest.getMessage(), url);
}
示例8: getUri
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
private URI getUri(HttpServletRequest request) {
StringBuffer builder = request.getRequestURL();
if (request.getQueryString() != null) {
builder.append("?").append(request.getQueryString());
}
return URI.create(builder.toString());
}
開發者ID:AndreyVMarkelov,項目名稱:prom-bitbucket-exporter,代碼行數:8,代碼來源:AdminMetricsSecurityTokenServlet.java
示例9: getRequestURL
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
/** Reconstruct the requested URL, complete with query string (if any). */
public static String getRequestURL(HttpServletRequest request) {
StringBuffer url = request.getRequestURL();
String queryString = request.getQueryString();
if (queryString != null) {
url.append("?").append(queryString);
}
return url.toString();
}
示例10: remove
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@RequestMapping(value = { "/name1", "/name2" }, produces = "text/plain;charset=UTF-8")//⑨
public @ResponseBody String remove(HttpServletRequest request) {
return "url:" + request.getRequestURL() + " can access";
}
示例11: index
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@RequestMapping(produces = "text/plain;charset=UTF-8") // ③
public @ResponseBody String index(HttpServletRequest request) { // ④
return "url:" + request.getRequestURL() + " can access";
}
示例12: remove
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@RequestMapping(value = {"/name1","/name2"},produces =
"text/plain;charset=UTF-8")
public @ResponseBody String remove(HttpServletRequest request){
return "url:"+ request.getRequestURL() + " can access";
}
示例13: demoPathVar
import javax.servlet.http.HttpServletRequest; //導入方法依賴的package包/類
@RequestMapping(value = "/pathvar/{str}", produces = "text/plain;charset=UTF-8")// ⑤
public @ResponseBody String demoPathVar(@PathVariable String str, //③
HttpServletRequest request) {
return "url:" + request.getRequestURL() + " can access,str: " + str;
}