Add delegation to the bean for the RequestMappingHandlerAdapter.getLastModifiedInternal(..) method if the bean implements the LastModified interface.

Comment From: pivotal-cla

@MarchenkoProjects Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

Comment From: pivotal-cla

@MarchenkoProjects Thank you for signing the Contributor License Agreement!

Comment From: rstoyanchev

Thanks for the suggestion, but this really needs to be more on the controller method level. Have you seen the options for a controller method?

Comment From: omarchenko4j

Yes, I saw it, but it will be located at the controller level anyway.

Let's imagine that my controller only manages one page, then it is very convenient to implement the logic of calculating the last modification without clogging the logic of page processing.

Take a look at an example:

@Controller
public class TestPageController implements LastModified {

    @GetMapping("/test/{id}")
    public ModelAndView getTest(@PathVariable String id) {
        // Model preparation.
        return new ModelAndView("pages/test_page");
    }

    @Override
    public long getLastModified(HttpServletRequest request) {
        return -1; // Calculate the last modified.
    }
}

Comment From: rstoyanchev

Team Decision: LastModified isn't a good fit for annotated controllers where multiple controller methods can be added at any time. It is also an outdated mechanism to be deprecated immediately in 5.3.x in favor of using ServerWebRequest#checkNotModified, or in a controller method, returning a ResponseEntity with "ETag" and/or "Last-Modified" headers set, which in turn delegates to checkNotModified.