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


Java ServletUriComponentsBuilder.fromCurrentRequest方法代码示例

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


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

示例1: fixLink

import org.springframework.web.servlet.support.ServletUriComponentsBuilder; //导入方法依赖的package包/类
Object fixLink(Object value) {
    if (!(value instanceof String)) {
        return value;
    }
    String href = (String) value;
    Matcher urlWithServiceNameMatcher = urlWithServiceNamePattern.matcher(href);
    Matcher standardUrlMatcher = standardUrlPattern.matcher(href);
    if (!standardUrlMatcher.matches() && urlWithServiceNameMatcher.matches()) {
        String possibleServiceName = urlWithServiceNameMatcher.group(1);
        log.debug("Possible service name: " + possibleServiceName);
        if (services.contains(possibleServiceName)) {
            log.debug("Service found");
            String gatewayPath = serviceRouteMapper.apply(possibleServiceName);
            String originalRestPath = urlWithServiceNameMatcher.group(2);
            ServletUriComponentsBuilder servletUriComponentsBuilder = ServletUriComponentsBuilder.fromCurrentRequest();
            UriComponents uriComponents = servletUriComponentsBuilder.replacePath(gatewayPath).path(originalRestPath).build();
            log.debug("Mapping " + value + " to " +  uriComponents);
            return uriComponents.toString();
        }
    }
    return href;
}
 
开发者ID:thomasletsch,项目名称:moserp,代码行数:23,代码来源:ResponseLinksMapper.java

示例2: buildFileUrl

import org.springframework.web.servlet.support.ServletUriComponentsBuilder; //导入方法依赖的package包/类
/**
 * Build a downLoadUrl for the file identified by the given fileId. If this method is called outside of a
 * request context ( system initialization for example) the server context is used for generating a relative path
 */
private String buildFileUrl(String fileId)
{

	if (RequestContextHolder.getRequestAttributes() != null)
	{
		ServletUriComponentsBuilder currentRequest = ServletUriComponentsBuilder.fromCurrentRequest();
		UriComponents downloadUri = currentRequest.replacePath(FileDownloadController.URI + '/' + fileId)
												  .replaceQuery(null)
												  .build();
		return downloadUri.toUriString();
	}
	else
	{
		// TODO this is a workaround for the situation where the File url needs to be created without a request
		// context, in order to fix the properly we would need to add a deploy time property
		// defining the file download server location
		return FileDownloadController.URI + '/' + fileId;
	}

}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:25,代码来源:StyleServiceImpl.java

示例3: index

import org.springframework.web.servlet.support.ServletUriComponentsBuilder; //导入方法依赖的package包/类
@RequestMapping(value = "/", method = RequestMethod.GET)
String index(Model model, //
		@QuerydslPredicate(root = User.class) Predicate predicate, //
		@PageableDefault(sort = { "lastname", "firstname" }) Pageable pageable, //
		@RequestParam MultiValueMap<String, String> parameters) {

	ServletUriComponentsBuilder builder = ServletUriComponentsBuilder.fromCurrentRequest();
	builder.replaceQueryParam("page", new Object[0]);

	model.addAttribute("baseUri", builder.build().toUri());
	model.addAttribute("users", repository.findAll(predicate, pageable));

	return "index";
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:15,代码来源:UserController.java

示例4: fromCurrentRequest

import org.springframework.web.servlet.support.ServletUriComponentsBuilder; //导入方法依赖的package包/类
public ServletUriComponentsBuilder fromCurrentRequest()
{
	return ServletUriComponentsBuilder.fromCurrentRequest();
}
 
开发者ID:molgenis,项目名称:molgenis,代码行数:5,代码来源:ServletUriComponentsBuilderFactory.java

示例5: uriComponentsBuilder

import org.springframework.web.servlet.support.ServletUriComponentsBuilder; //导入方法依赖的package包/类
/**
 * Construct a {@link UriComponentsBuilder} with the current http request.
 *
 * @return A request scope {@link UriComponentsBuilder} bean.
 * @since 1.0.0
 */
@Bean
@Scope(value = WebApplicationContext.SCOPE_REQUEST, proxyMode = ScopedProxyMode.TARGET_CLASS)
public UriComponentsBuilder uriComponentsBuilder() {
	return ServletUriComponentsBuilder.fromCurrentRequest();
}
 
开发者ID:cmateosl,项目名称:role-api,代码行数:12,代码来源:Application.java


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