本文整理汇总了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);
}
}
示例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();
}
示例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();
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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")));
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}