Search in sources :

Example 6 with ParameterizableViewController

use of org.springframework.web.servlet.mvc.ParameterizableViewController in project cas by apereo.

the class CasApplicationContextConfiguration method rootController.

@Bean
protected Controller rootController() {
    return new ParameterizableViewController() {

        @Override
        protected ModelAndView handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
            final String queryString = request.getQueryString();
            final String url = request.getContextPath() + "/login" + (queryString != null ? '?' + queryString : StringUtils.EMPTY);
            return new ModelAndView(new RedirectView(response.encodeURL(url)));
        }
    };
}
Also used : ParameterizableViewController(org.springframework.web.servlet.mvc.ParameterizableViewController) HttpServletRequest(javax.servlet.http.HttpServletRequest) ModelAndView(org.springframework.web.servlet.ModelAndView) RedirectView(org.springframework.web.servlet.view.RedirectView) HttpServletResponse(javax.servlet.http.HttpServletResponse) Bean(org.springframework.context.annotation.Bean)

Example 7 with ParameterizableViewController

use of org.springframework.web.servlet.mvc.ParameterizableViewController in project spring-framework by spring-projects.

the class ViewControllerRegistryTests method getController.

private ParameterizableViewController getController(String path) {
    Map<String, ?> urlMap = getHandlerMapping().getUrlMap();
    ParameterizableViewController controller = (ParameterizableViewController) urlMap.get(path);
    assertNotNull(controller);
    return controller;
}
Also used : ParameterizableViewController(org.springframework.web.servlet.mvc.ParameterizableViewController)

Example 8 with ParameterizableViewController

use of org.springframework.web.servlet.mvc.ParameterizableViewController in project spring-framework by spring-projects.

the class ViewControllerRegistryTests method addViewController.

@Test
public void addViewController() {
    this.registry.addViewController("/path").setViewName("viewName");
    ParameterizableViewController controller = getController("/path");
    assertEquals("viewName", controller.getViewName());
    assertNull(controller.getStatusCode());
    assertFalse(controller.isStatusOnly());
    assertNotNull(controller.getApplicationContext());
}
Also used : ParameterizableViewController(org.springframework.web.servlet.mvc.ParameterizableViewController) Test(org.junit.Test)

Aggregations

ParameterizableViewController (org.springframework.web.servlet.mvc.ParameterizableViewController)8 Test (org.junit.Test)4 RedirectView (org.springframework.web.servlet.view.RedirectView)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 Bean (org.springframework.context.annotation.Bean)2 ModelAndView (org.springframework.web.servlet.ModelAndView)2 ServletListenerRegistrationBean (org.springframework.boot.web.servlet.ServletListenerRegistrationBean)1 BeanNameUrlHandlerMapping (org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping)1 SimpleUrlHandlerMapping (org.springframework.web.servlet.handler.SimpleUrlHandlerMapping)1