/** * Map a simple controller to the given URL path (or pattern) in order to * set the response status to the given code without rendering a body. * @since 4.1 */ public void addStatusController(String urlPath, HttpStatus statusCode) { ViewControllerRegistration registration = new ViewControllerRegistration(urlPath); registration.setApplicationContext(this.applicationContext); registration.setStatusCode(statusCode); registration.getViewController().setStatusOnly(true); this.registrations.add(registration); }
/** * Return the {@code HandlerMapping} that contains the registered view * controller mappings, or {@code null} for no registrations. * @since 4.3.12 */ @Nullable protected SimpleUrlHandlerMapping buildHandlerMapping() { if (this.registrations.isEmpty() && this.redirectRegistrations.isEmpty()) { return null; } Map<String, Object> urlMap = new LinkedHashMap<>(); for (ViewControllerRegistration registration : this.registrations) { urlMap.put(registration.getUrlPath(), registration.getViewController()); } for (RedirectViewControllerRegistration registration : this.redirectRegistrations) { urlMap.put(registration.getUrlPath(), registration.getViewController()); } SimpleUrlHandlerMapping handlerMapping = new SimpleUrlHandlerMapping(); handlerMapping.setUrlMap(urlMap); handlerMapping.setOrder(this.order); return handlerMapping; }
/** * Map a simple controller to the given URL path (or pattern) in order to * set the response status to the given code without rendering a body. * @since 4.1 */ public void addStatusController(String urlPath, HttpStatus statusCode) { ViewControllerRegistration registration = new ViewControllerRegistration(urlPath); registration.setApplicationContext(this.applicationContext); registration.setStatusCode(statusCode); registration.getViewController().setStatusOnly(true); this.registrations.add(registration); }
/** * Return the {@code HandlerMapping} that contains the registered view * controller mappings, or {@code null} for no registrations. * @since 4.3.12 */ @Nullable protected SimpleUrlHandlerMapping buildHandlerMapping() { if (this.registrations.isEmpty() && this.redirectRegistrations.isEmpty()) { return null; } Map<String, Object> urlMap = new LinkedHashMap<>(); for (ViewControllerRegistration registration : this.registrations) { urlMap.put(registration.getUrlPath(), registration.getViewController()); } for (RedirectViewControllerRegistration registration : this.redirectRegistrations) { urlMap.put(registration.getUrlPath(), registration.getViewController()); } SimpleUrlHandlerMapping handlerMapping = new SimpleUrlHandlerMapping(); handlerMapping.setUrlMap(urlMap); handlerMapping.setOrder(this.order); return handlerMapping; }
/** * Map a simple controller to the given URL path (or pattern) in order to * set the response status to the given code without rendering a body. * @since 4.1 */ public void addStatusController(String urlPath, HttpStatus statusCode) { ViewControllerRegistration registration = new ViewControllerRegistration(urlPath); registration.setApplicationContext(this.applicationContext); registration.setStatusCode(statusCode); registration.getViewController().setStatusOnly(true); this.registrations.add(registration); }