當前位置: 首頁>>代碼示例>>Java>>正文


Java HttpServletRequest.getRequestURL方法代碼示例

本文整理匯總了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();

}
 
開發者ID:longjiazuo,項目名稱:springMvc4.x-project,代碼行數:9,代碼來源:DemoAnnoController.java

示例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);

}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:19,代碼來源:PSPMockRegistrationEntry.java

示例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();
}
 
開發者ID:sunzhen086,項目名稱:lambo,代碼行數:24,代碼來源:RequestParameterUtil.java

示例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;
}
 
開發者ID:sunzhen086,項目名稱:lambo,代碼行數:22,代碼來源:UpmsAuthenticationFilter.java

示例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);
}
 
開發者ID:liufeng0103,項目名稱:bnade-web-ssh,代碼行數:10,代碼來源:ExceptionHandle.java

示例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();
}
 
開發者ID:wittyLuzhishen,項目名稱:EasyPackage,代碼行數:10,代碼來源:InvocationUtil.java

示例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);
}
 
開發者ID:liufeng0103,項目名稱:bnade-web-ssh,代碼行數:14,代碼來源:ExceptionHandle.java

示例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();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:10,代碼來源:OAuthServlet.java

示例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";
}
 
開發者ID:longjiazuo,項目名稱:springMvc4.x-project,代碼行數:6,代碼來源:DemoAnnoController.java

示例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";
}
 
開發者ID:longjiazuo,項目名稱:springMvc4.x-project,代碼行數:5,代碼來源:DemoAnnoController.java

示例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";
}
 
開發者ID:shuaishuaila,項目名稱:java_springboot,代碼行數:6,代碼來源:DemoAnnoController.java

示例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;
}
 
開發者ID:longjiazuo,項目名稱:springMvc4.x-project,代碼行數:6,代碼來源:DemoAnnoController.java


注:本文中的javax.servlet.http.HttpServletRequest.getRequestURL方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。