001/* 002 * Copyright 2002-2012 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.web.servlet.mvc; 018 019import javax.servlet.http.HttpServletRequest; 020 021/** 022 * Supports last-modified HTTP requests to facilitate content caching. 023 * Same contract as for the Servlet API's {@code getLastModified} method. 024 * 025 * <p>Delegated to by a {@link org.springframework.web.servlet.HandlerAdapter#getLastModified} 026 * implementation. By default, any Controller or HttpRequestHandler within Spring's 027 * default framework can implement this interface to enable last-modified checking. 028 * 029 * <p><b>Note:</b> Alternative handler implementation approaches have different 030 * last-modified handling styles. For example, Spring 2.5's annotated controller 031 * approach (using {@code @RequestMapping}) provides last-modified support 032 * through the {@link org.springframework.web.context.request.WebRequest#checkNotModified} 033 * method, allowing for last-modified checking within the main handler method. 034 * 035 * @author Rod Johnson 036 * @author Juergen Hoeller 037 * @see javax.servlet.http.HttpServlet#getLastModified 038 * @see Controller 039 * @see SimpleControllerHandlerAdapter 040 * @see org.springframework.web.HttpRequestHandler 041 * @see HttpRequestHandlerAdapter 042 */ 043public interface LastModified { 044 045 /** 046 * Same contract as for HttpServlet's {@code getLastModified} method. 047 * Invoked <b>before</b> request processing. 048 * <p>The return value will be sent to the HTTP client as Last-Modified header, 049 * and compared with If-Modified-Since headers that the client sends back. 050 * The content will only get regenerated if there has been a modification. 051 * @param request current HTTP request 052 * @return the time the underlying resource was last modified, or -1 053 * meaning that the content must always be regenerated 054 * @see org.springframework.web.servlet.HandlerAdapter#getLastModified 055 * @see javax.servlet.http.HttpServlet#getLastModified 056 */ 057 long getLastModified(HttpServletRequest request); 058 059}