Example usage for org.springframework.web.servlet.config.annotation ViewControllerRegistry addRedirectViewController

List of usage examples for org.springframework.web.servlet.config.annotation ViewControllerRegistry addRedirectViewController

Introduction

In this page you can find the example usage for org.springframework.web.servlet.config.annotation ViewControllerRegistry addRedirectViewController.

Prototype

public RedirectViewControllerRegistration addRedirectViewController(String urlPath, String redirectUrl) 

Source Link

Document

Map a view controller to the given URL path (or pattern) in order to redirect to another URL.

Usage

From source file:io.spring.initializr.web.autoconfigure.InitializrWebConfig.java

@Override
public void addViewControllers(ViewControllerRegistry registry) {
    registry.addRedirectViewController("/info", "/actuator/info");
}

From source file:com.github.springfox.loader.SpringfoxLoaderConfig.java

@Override
public void addViewControllers(ViewControllerRegistry registry) {
    if (!StringUtils.isEmpty(springfoxLoader.swaggerUiBasePath())) {
        registry.addRedirectViewController(resourcePath("/v2/api-docs"), "/v2/api-docs");
        registry.addRedirectViewController(resourcePath("/swagger-resources/configuration/ui"),
                "/swagger-resources/configuration/ui");
        registry.addRedirectViewController(resourcePath("/swagger-resources/configuration/security"),
                "/swagger-resources/configuration/security");
        registry.addRedirectViewController(resourcePath("/swagger-resources"), "/swagger-resources");
    }//from  ww w . j av  a 2s. c  o m
}

From source file:de.codecentric.boot.admin.config.AdminServerWebConfiguration.java

@Override
public void addViewControllers(ViewControllerRegistry registry) {
    if (StringUtils.hasText(adminServerProperties().getContextPath())) {
        registry.addRedirectViewController(adminServerProperties().getContextPath(),
                server.getPath(adminServerProperties().getContextPath()) + "/");
    }//w w  w . ja v  a2 s .co m
    registry.addViewController(adminServerProperties().getContextPath() + "/")
            .setViewName("forward:index.html");
}

From source file:org.meruvian.yama.webapi.config.WebConfig.java

@Override
public void addViewControllers(ViewControllerRegistry registry) {
    log.debug("Configure view controllers");
    super.addViewControllers(registry);

    registry.addViewController("/login").setViewName("forward:/login.html");
    registry.addViewController("/register").setViewName("forward:/register.html");
    registry.addRedirectViewController("/oauth/approval", "/oauth_approval").setKeepQueryParams(true);
    registry.addViewController("/oauth_approval").setViewName("forward:/oauth_approval.html");
}

From source file:org.smigo.config.WebConfiguration.java

@Override
public void addViewControllers(ViewControllerRegistry registry) {
    registry.addViewController("/garden-planner-comparison").setViewName("garden-planner-comparison.jsp");
    registry.addViewController("/").setViewName("home.jsp");
    registry.addViewController("/help").setViewName("help.jsp");
    registry.addViewController("/robots.txt").setViewName("robots-txt.jsp");
    registry.addViewController("/sitemap.xml").setViewName("sitemap-xml.jsp");
    registry.addRedirectViewController("/garden-planner.html", "/views/garden-planner.html")
            .setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    registry.addRedirectViewController("/garden/**", "/garden-planner")
            .setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    registry.addRedirectViewController("/hasta-luego/**", "/welcome-back")
            .setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    registry.addRedirectViewController("/beta/**", "/").setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    registry.addRedirectViewController("/accept-termsofservice/**", "/accept-terms-of-service")
            .setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    registry.addRedirectViewController("/signup/**", "/register").setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    registry.addRedirectViewController("/_=_", "/garden-planner").setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    registry.addRedirectViewController("/wall/{username}/**", "/gardener/{username}")
            .setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    registry.addRedirectViewController("/tos.html", "/static/terms-of-service.html")
            .setStatusCode(HttpStatus.MOVED_PERMANENTLY);
    registry.addStatusController("/static/terms-of-service.html", HttpStatus.GONE);
    registry.addStatusController("/listspecies", HttpStatus.GONE);
    registry.addStatusController("/update-species", HttpStatus.GONE);
    registry.addStatusController("/rest/species/search", HttpStatus.GONE);
    registry.addStatusController("/addyear/**", HttpStatus.GONE);
    registry.addStatusController("/deletespecies/**", HttpStatus.GONE);
    registry.addStatusController("/species/**", HttpStatus.GONE);
    registry.addStatusController("/rule/**", HttpStatus.GONE);
    registry.addStatusController("**/*.php", HttpStatus.NOT_FOUND);
    registry.addStatusController("cgi-bin/**", HttpStatus.NOT_FOUND);
    registry.addStatusController("**/*.cgi", HttpStatus.NOT_FOUND);
    registry.addStatusController("/wp/", HttpStatus.NOT_FOUND);
    registry.addStatusController("/wordpress/", HttpStatus.NOT_FOUND);
    registry.addStatusController("/HNAP1/", HttpStatus.NOT_FOUND);
    registry.addStatusController("/blog/robots.txt", HttpStatus.NOT_FOUND);
    registry.addStatusController("/apple-touch-icon-precomposed.png", HttpStatus.NOT_FOUND);
    registry.addStatusController("/apple-touch-icon.png", HttpStatus.NOT_FOUND);
}