List of usage examples for org.springframework.web.servlet.support ServletUriComponentsBuilder fragment
@Override
public UriComponentsBuilder fragment(@Nullable String fragment)
From source file:com.microservice.training.hal.HalBrowser.java
/** * Returns the View to redirect to to access the HAL browser. * /*ww w . j a v a2 s . c o m*/ * @param request must not be {@literal null}. * @param browserRelative * @return */ private View getRedirectView(HttpServletRequest request, boolean browserRelative) { ServletUriComponentsBuilder builder = ServletUriComponentsBuilder.fromRequest(request); UriComponents components = builder.build(); String path = components.getPath() == null ? "" : components.getPath(); if (!browserRelative) { builder.path(BROWSER); } builder.path(INDEX); builder.fragment(browserRelative ? path.substring(0, path.lastIndexOf("/browser")) : path); return new RedirectView(builder.build().toUriString()); }