Announcement Announcement Module
No announcement yet.
Last-Modified header with @Controller annotation Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Last-Modified header with @Controller annotation


    I'm implementting a REST web service based on a MVC @Controller annotated class. I've implemented the Etag functionality with the provided Filter and I'd like to include the Last-Modified header when returning the resource representations too. I've seen that there is a LastModified interface which should be implemented by the controller, but my problem is that I want to include the mentioned header for some of the methods implementing the REST API, and I don't know how to accomplish it.

    By the way, I'm using Spring 3.0.5

    Please, could anybody provide some hint?

    Best regards,
    Juan Carlos

  • #2
    Perhaps there is a better way, but you can just do it manually:

    @RequestMapping("getDigitizingContent/{panelName}/{versionNumber}")    public String getDigitizingContentByPanelNameWithVersionHandler(@PathVariable String panelName, Model model, HttpServletResponse response) {
            response.setHeader("Cache-Control", "public, max-age=31556926"); 
            response.setDateHeader("Last-Modified", lastModifiedDate);
    return model; //etc