当前位置: 首页>>代码示例>>Java>>正文


Java UriComponents.toUriString方法代码示例

本文整理汇总了Java中org.springframework.web.util.UriComponents.toUriString方法的典型用法代码示例。如果您正苦于以下问题:Java UriComponents.toUriString方法的具体用法?Java UriComponents.toUriString怎么用?Java UriComponents.toUriString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.web.util.UriComponents的用法示例。


在下文中一共展示了UriComponents.toUriString方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRedirectUrl

import org.springframework.web.util.UriComponents; //导入方法依赖的package包/类
String getRedirectUrl(HttpServletRequest request) {
    String requestUrl = request.getRequestURL().toString();
    try {
        URI uri = new URI(requestUrl);
        UriComponents uriComponents = UriComponentsBuilder.newInstance()
            .scheme("https")
            .host(uri.getHost())
            .path(uri.getPath())
            .query(uri.getQuery())
            .fragment(uri.getFragment())
            .build();
        return uriComponents.toUriString();
    } catch (URISyntaxException e) {
        throw new RuntimeException("Could not parse URL [" + requestUrl + "]", e);
    }
}
 
开发者ID:AusDTO,项目名称:citizenship-appointment-server,代码行数:17,代码来源:HttpsOnlyFilter.java

示例2: generateUserPictureUrl

import org.springframework.web.util.UriComponents; //导入方法依赖的package包/类
/**
 * 회원 프로필 이미지 URL을 생성한다.
 *
 * @param sizeType size 타입
 * @param id UserImage의 ID
 */
public String generateUserPictureUrl(Constants.IMAGE_SIZE_TYPE sizeType, String id) {

    if (StringUtils.isBlank(id))
        return null;

    String urlPathUserPicture = null;

    switch (sizeType) {
        case LARGE:
            urlPathUserPicture = jakdukProperties.getApiUrlPath().getUserPictureLarge();
            break;
        case SMALL:
            urlPathUserPicture = jakdukProperties.getApiUrlPath().getUserPictureSmall();
            break;
    }

    UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl(jakdukProperties.getApiServerUrl())
            .path("/{urlPathGallery}/{id}")
            .buildAndExpand(urlPathUserPicture, id);

    return uriComponents.toUriString();
}
 
开发者ID:JakduK,项目名称:jakduk-api,代码行数:29,代码来源:AuthUtils.java

示例3: generateGalleryUrl

import org.springframework.web.util.UriComponents; //导入方法依赖的package包/类
/**
 * 사진첩 이미지 URL을 생성한다.
 *
 * @param sizeType size 타입
 * @param id Gallery ID
 */
public String generateGalleryUrl(Constants.IMAGE_SIZE_TYPE sizeType, String id) {

    if (StringUtils.isBlank(id))
        return null;

    String urlPathGallery = null;

    switch (sizeType) {
        case LARGE:
            urlPathGallery = apiUrlPathProperties.getGalleryImage();
            break;
        case SMALL:
            urlPathGallery = apiUrlPathProperties.getGalleryThumbnail();
            break;
    }

    UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl(jakdukProperties.getApiServerUrl())
            .path("/{urlPathGallery}/{id}")
            .buildAndExpand(urlPathGallery, id);

    return uriComponents.toUriString();
}
 
开发者ID:JakduK,项目名称:jakduk-api,代码行数:29,代码来源:UrlGenerationUtils.java

示例4: createUri

import org.springframework.web.util.UriComponents; //导入方法依赖的package包/类
private URI createUri(String uriTemplate, UriComponentsBuilder builder, UriComponents uriComponents) {
  String strUri = uriComponents.toUriString();

  if (isCrossApp(uriTemplate, builder)) {
    int idx = strUri.indexOf('/', RestConst.URI_PREFIX.length());
    strUri = strUri.substring(0, idx) + ":" + strUri.substring(idx + 1);
  }

  try {
    // Avoid further encoding (in the case of strictEncoding=true)
    return new URI(strUri);
  } catch (URISyntaxException ex) {
    throw new IllegalStateException("Could not create URI object: " + ex.getMessage(), ex);
  }
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:16,代码来源:CseUriTemplateHandler.java

示例5: validateFile

import org.springframework.web.util.UriComponents; //导入方法依赖的package包/类
@GetMapping(value = "/validate/{filename:.+}")
public ModelAndView validateFile(@PathVariable String filename, @QueryParam(
    "version") ValidationService.MzTabVersion version, @QueryParam(
    "maxErrors") int maxErrors, HttpServletRequest request,
    HttpSession session) {
    if (session == null) {
        UriComponents uri = ServletUriComponentsBuilder
            .fromServletMapping(request).
            build();
        return new ModelAndView(
            "redirect:" + uri.toUriString());
    }
    ModelAndView modelAndView = new ModelAndView("validationResult");
    modelAndView.
        addObject("page", new Page("mzTabValidator", versionNumber, gaId));
    modelAndView.addObject("validationFile", filename);
    ValidationService.MzTabVersion validationVersion = version;
    if (validationVersion != null) {
        modelAndView.addObject("validationVersion", validationVersion);
    } else {
        validationVersion = ValidationService.MzTabVersion.MZTAB_1_1;
        modelAndView.addObject("validationVersion", validationVersion);
    }
    if (maxErrors > 0) {
        modelAndView.addObject("validationMaxErrors", maxErrors);
    } else {
        modelAndView.addObject("validationMaxErrors", 100);
    }
    UserSessionFile usf = new UserSessionFile(filename, session.getId());
    modelAndView.addObject("validationResults", validationService.
        asValidationResults(validationService.validate(
            validationVersion, usf, maxErrors)));
    return modelAndView;
}
 
开发者ID:nilshoffmann,项目名称:jmzTab-m,代码行数:35,代码来源:ValidationController.java

示例6: getRedirectUrl

import org.springframework.web.util.UriComponents; //导入方法依赖的package包/类
protected String getRedirectUrl(HttpServletRequest request) {
    String requestUrl = request.getRequestURL().toString();
    try {
        URI uri = new URI(requestUrl);
        UriComponents uriComponents = UriComponentsBuilder.newInstance()
                .scheme("https")
                .host(uri.getHost())
                .path(uri.getPath())
                .query(uri.getQuery())
                .build();
        return uriComponents.toUriString();
    } catch (URISyntaxException e) {
        throw new RuntimeException("Could not parse URL [" + requestUrl + "]", e);
    }
}
 
开发者ID:AusDTO,项目名称:spring-security-stateless,代码行数:16,代码来源:HttpsOnlyFilter.java

示例7: returnsTheElectorsWhenSearchingByAttributes

import org.springframework.web.util.UriComponents; //导入方法依赖的package包/类
@Test
public void returnsTheElectorsWhenSearchingByAttributes() throws Exception {
    when(sessionService.extractUserFromPrincipal(any(Principal.class)))
            .thenReturn(Try.success(earlsdon()));
    pafApiStub.willSearchVoters("CV46PL", "McCall", "E05001221");

    MultiValueMap<String, String> params = new LinkedMultiValueMap<>();
    params.add("surname", "McCall");
    params.add("postcode", "CV46PL");
    params.add("wardCode", "E05001221");
    UriComponents uriComponents = UriComponentsBuilder.fromPath("/elector")
            .queryParams(params)
            .build();

    String url = uriComponents.toUriString();

    mockMvc.perform(get(url)
            .accept(APPLICATION_JSON))
            .andDo(print())
            .andExpect(status().isOk())
            .andExpect(jsonPath("$[0].full_name", is("McCall, John B")))
            .andExpect(jsonPath("$[0].first_name", is("John B")))
            .andExpect(jsonPath("$[0].surname", is("McCall")))
            .andExpect(jsonPath("$[0].ern", is("E050097474-LFF-305-0")))
            .andExpect(jsonPath("$[0].address.postcode", is("CV4 6PL")))
            .andExpect(jsonPath("$[0].address.line_1", is("Grange Farm House")))
            .andExpect(jsonPath("$[0].address.line_2", is("Crompton Lane")))
            .andExpect(jsonPath("$[0].address.post_town", is("Coventry")));
}
 
开发者ID:celestial-winter,项目名称:vics,代码行数:30,代码来源:VoterTest.java

示例8: getServerAddress

import org.springframework.web.util.UriComponents; //导入方法依赖的package包/类
private String getServerAddress(HttpServletRequest request) {
    UriComponents build = UriComponentsBuilder
            .newInstance()
            .scheme(request.getScheme())
            .host(request.getServerName())
            .port(request.getServerPort())
            .build();
    return build.toUriString();
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:10,代码来源:DiscoveryNodeController.java

示例9: process

import org.springframework.web.util.UriComponents; //导入方法依赖的package包/类
@Override
public Resource<Person> process(Resource<Person> resource) {
	String id = Long.toString(resource.getContent().getId());
	UriComponents uriComponents = ServletUriComponentsBuilder.fromCurrentContextPath()
			.path("/people/{id}/photo").buildAndExpand(id);
	String uri = uriComponents.toUriString();
	resource.add(new Link(uri, "photo"));
	return resource;
}
 
开发者ID:livelessons-spring,项目名称:building-microservices,代码行数:10,代码来源:PersonResourceProcessor.java

示例10: generateArticleDetailApiUrl

import org.springframework.web.util.UriComponents; //导入方法依赖的package包/类
/**
 * 글 상세 API URL 생성
 *
 * @param board 게시판
 * @param seq 글번호
 */
public String generateArticleDetailApiUrl(String board, Integer seq) {

    if (StringUtils.isBlank(board) || Objects.isNull(seq))
        return null;

    UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl(jakdukProperties.getApiServerUrl())
            .path("/api/board/{board}/{seq}")
            .buildAndExpand(board.toLowerCase(), seq);

    return uriComponents.toUriString();
}
 
开发者ID:JakduK,项目名称:jakduk-api,代码行数:18,代码来源:UrlGenerationUtils.java

示例11: generateArticleDetailUrl

import org.springframework.web.util.UriComponents; //导入方法依赖的package包/类
/**
 * 글 상세 URL 생성
 *
 * @param board 게시판
 * @param seq 글번호
 */
public String generateArticleDetailUrl(String board, Integer seq) {

    if (StringUtils.isBlank(board) || Objects.isNull(seq))
        return null;

    UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl(jakdukProperties.getWebServerUrl())
            .path("/board/{board}/{seq}")
            .buildAndExpand(board.toLowerCase(), seq);

    return uriComponents.toUriString();
}
 
开发者ID:JakduK,项目名称:jakduk-api,代码行数:18,代码来源:UrlGenerationUtils.java


注:本文中的org.springframework.web.util.UriComponents.toUriString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。