Skip to content

Conversation

@omarchenko4j
Copy link

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

…stModifiedInternal(..) method if the bean implements the LastModified interface
@pivotal-cla
Copy link

@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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 18, 2021
@pivotal-cla
Copy link

@MarchenkoProjects Thank you for signing the Contributor License Agreement!

@rstoyanchev
Copy link
Contributor

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?

@rstoyanchev rstoyanchev added the status: waiting-for-feedback We need additional information before we can continue label Jul 9, 2021
@omarchenko4j
Copy link
Author

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.
    }
}

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jul 10, 2021
@rstoyanchev
Copy link
Contributor

rstoyanchev commented Jul 13, 2021

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.

@rstoyanchev rstoyanchev added status: declined A suggestion or change that we don't feel we should currently apply and removed for: team-attention status: feedback-provided Feedback has been provided status: waiting-for-triage An issue we've not yet triaged or decided on labels Jul 13, 2021
rstoyanchev added a commit that referenced this pull request Jul 13, 2021
lxbzmy pushed a commit to lxbzmy/spring-framework that referenced this pull request Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: declined A suggestion or change that we don't feel we should currently apply

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants