All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.springframework.web.servlet.HandlerAdapter Maven / Gradle / Ivy

There is a newer version: 6.2.0
Show newest version
/*
 * Copyright 2002-2021 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.web.servlet;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import org.springframework.lang.Nullable;

/**
 * MVC framework SPI, allowing parameterization of the core MVC workflow.
 *
 * 

Interface that must be implemented for each handler type to handle a request. * This interface is used to allow the {@link DispatcherServlet} to be indefinitely * extensible. The {@code DispatcherServlet} accesses all installed handlers through * this interface, meaning that it does not contain code specific to any handler type. * *

Note that a handler can be of type {@code Object}. This is to enable * handlers from other frameworks to be integrated with this framework without * custom coding, as well as to allow for annotation-driven handler objects that * do not obey any specific Java interface. * *

This interface is not intended for application developers. It is available * to handlers who want to develop their own web workflow. * *

Note: {@code HandlerAdapter} implementors may implement the {@link * org.springframework.core.Ordered} interface to be able to specify a sorting * order (and thus a priority) for getting applied by the {@code DispatcherServlet}. * Non-Ordered instances get treated as the lowest priority. * * @author Rod Johnson * @author Juergen Hoeller * @see org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter * @see org.springframework.web.servlet.handler.SimpleServletHandlerAdapter */ public interface HandlerAdapter { /** * Given a handler instance, return whether this {@code HandlerAdapter} * can support it. Typical HandlerAdapters will base the decision on the handler * type. HandlerAdapters will usually only support one handler type each. *

A typical implementation: *

{@code * return (handler instanceof MyHandler); * } * @param handler the handler object to check * @return whether this object can use the given handler */ boolean supports(Object handler); /** * Use the given handler to handle this request. * The workflow that is required may vary widely. * @param request current HTTP request * @param response current HTTP response * @param handler the handler to use. This object must have previously been passed * to the {@code supports} method of this interface, which must have * returned {@code true}. * @return a ModelAndView object with the name of the view and the required * model data, or {@code null} if the request has been handled directly * @throws Exception in case of errors */ @Nullable ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception; /** * Same contract as for HttpServlet's {@code getLastModified} method. * Can simply return -1 if there's no support in the handler class. * @param request current HTTP request * @param handler the handler to use * @return the lastModified value for the given handler * @deprecated as of 5.3.9 along with * {@link org.springframework.web.servlet.mvc.LastModified}. */ @Deprecated long getLastModified(HttpServletRequest request, Object handler); }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy