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) {
final String queryString = request.getQueryString();
final String url = request.getContextPath() + "/login" + (queryString != null ? '?' + queryString : StringUtils.EMPTY);
return new ModelAndView(new RedirectView(response.encodeURL(url)));
}
};
}
use of org.springframework.web.servlet.mvc.ParameterizableViewController in project spring-framework by spring-projects.
the class MvcNamespaceTests method testViewControllersDefaultConfig.
@Test
public void testViewControllersDefaultConfig() {
loadBeanDefinitions("mvc-config-view-controllers-minimal.xml");
SimpleUrlHandlerMapping hm = this.appContext.getBean(SimpleUrlHandlerMapping.class);
assertThat(hm).isNotNull();
ParameterizableViewController viewController = (ParameterizableViewController) hm.getUrlMap().get("/path");
assertThat(viewController).isNotNull();
assertThat(viewController.getViewName()).isEqualTo("home");
ParameterizableViewController redirectViewController = (ParameterizableViewController) hm.getUrlMap().get("/old");
assertThat(redirectViewController).isNotNull();
assertThat(redirectViewController.getView()).isInstanceOf(RedirectView.class);
ParameterizableViewController statusViewController = (ParameterizableViewController) hm.getUrlMap().get("/bad");
assertThat(statusViewController).isNotNull();
assertThat(statusViewController.getStatusCode().value()).isEqualTo(404);
BeanNameUrlHandlerMapping beanNameMapping = this.appContext.getBean(BeanNameUrlHandlerMapping.class);
assertThat(beanNameMapping).isNotNull();
assertThat(beanNameMapping.getOrder()).isEqualTo(2);
}
use of org.springframework.web.servlet.mvc.ParameterizableViewController in project spring-framework by spring-projects.
the class ViewControllerRegistryTests method getRedirectView.
private RedirectView getRedirectView(String path) {
ParameterizableViewController controller = getController(path);
assertThat(controller.getViewName()).isNull();
assertThat(controller.getView()).isNotNull();
assertThat(controller.getView().getClass()).isEqualTo(RedirectView.class);
return (RedirectView) controller.getView();
}
use of org.springframework.web.servlet.mvc.ParameterizableViewController in project spring-framework by spring-projects.
the class ViewControllerRegistryTests method addViewControllerWithDefaultViewName.
@Test
public void addViewControllerWithDefaultViewName() {
this.registry.addViewController("/path");
ParameterizableViewController controller = getController("/path");
assertThat(controller.getViewName()).isNull();
assertThat(controller.getStatusCode()).isNull();
assertThat(controller.isStatusOnly()).isFalse();
assertThat(controller.getApplicationContext()).isNotNull();
}
use of org.springframework.web.servlet.mvc.ParameterizableViewController in project spring-framework by spring-projects.
the class ViewControllerRegistryTests method addStatusController.
@Test
public void addStatusController() {
this.registry.addStatusController("/path", HttpStatus.NOT_FOUND);
ParameterizableViewController controller = getController("/path");
assertThat(controller.getViewName()).isNull();
assertThat(controller.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
assertThat(controller.isStatusOnly()).isTrue();
assertThat(controller.getApplicationContext()).isNotNull();
}
Aggregations