/** * Whether to interpret a given redirect URL that starts with a slash ("/") * as relative to the current ServletContext, i.e. as relative to the web * application root. * <p>Default is {@code true}. */ public RedirectViewControllerRegistration setContextRelative(boolean contextRelative) { this.redirectView.setContextRelative(contextRelative); return this; }
/** * Whether to interpret a given redirect URL that starts with a slash ("/") * as relative to the current ServletContext, i.e. as relative to the web * application root. * <p>Default is {@code true}. */ public RedirectViewControllerRegistration setContextRelative(boolean contextRelative) { this.redirectView.setContextRelative(contextRelative); return this; }
public RedirectViewControllerRegistration(String urlPath, String redirectUrl) { Assert.notNull(urlPath, "'urlPath' is required."); Assert.notNull(redirectUrl, "'redirectUrl' is required."); this.urlPath = urlPath; this.redirectView = new RedirectView(redirectUrl); this.redirectView.setContextRelative(true); this.controller.setView(this.redirectView); }
public RedirectViewControllerRegistration(String urlPath, String redirectUrl) { Assert.notNull(urlPath, "'urlPath' is required."); Assert.notNull(redirectUrl, "'redirectUrl' is required."); this.urlPath = urlPath; this.redirectView = new RedirectView(redirectUrl); this.redirectView.setContextRelative(true); this.controller.setView(this.redirectView); }
/** * Whether to interpret a given redirect URL that starts with a slash ("/") * as relative to the current ServletContext, i.e. as relative to the web * application root. * <p>Default is {@code true}. */ public RedirectViewControllerRegistration setContextRelative(boolean contextRelative) { this.redirectView.setContextRelative(contextRelative); return this; }
public RedirectViewControllerRegistration(String urlPath, String redirectUrl) { Assert.notNull(urlPath, "'urlPath' is required."); Assert.notNull(redirectUrl, "'redirectUrl' is required."); this.urlPath = urlPath; this.redirectView = new RedirectView(redirectUrl); this.redirectView.setContextRelative(true); this.controller.setView(this.redirectView); }
private Object resolveZone(HttpServletRequest request, String decodedRawZone, Function<ZoneInfo, ModelAndView> onZoneInfo) { // note that decodedRawZone already do http url decode, and PathVariable already trim() // space of value return Zone.tryFallback(decodedRawZone).map(zone -> { if (!zone.value().equals(decodedRawZone)) { String orgUrl = request.getRequestURL().toString(); // replace pattern is combine of fallback pattern and valid pattern // TODO refactor replace rule to Zone String location = orgUrl.replaceFirst("/z/[a-zA-Z0-9_\\-]+", "/z/" + zone); //check if fallback success, this prevent infinite redirect loop if (!location.equals(orgUrl)) { RedirectView redirectView = new RedirectView(location); redirectView.setPropagateQueryParams(true); redirectView.setExpandUriTemplateVariables(false); redirectView.setExposeModelAttributes(false); redirectView.setExposeContextBeansAsAttributes(false); redirectView.setExposePathVariables(false); redirectView.setContextRelative(true); redirectView.setStatusCode(HttpStatus.PERMANENT_REDIRECT); return redirectView; } } return onZoneInfo.apply(zoneService.loadZone(zone)); }).orElseThrow(() -> new EmptyResultDataAccessException("no such zone: " + decodedRawZone, 1)); }