Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify RedirectView to allow 301 Permanent Redirects [SPR-5468] #10141

Closed
spring-projects-issues opened this issue Feb 9, 2009 · 2 comments
Closed
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Feb 9, 2009

Scott Murphy opened SPR-5468 and commented

There are numerous occasions where I need to use a redirect view to permanently redirect traffic based on an old url. For SEO purposes, a permanent redirect is preferred over a temporary one for transferring pagerank to the new url. (See: http://www.mcanerin.com/EN/articles/301-redirect-scripting.asp)

Please provide a way to specify the type of redirection (permanent vs temporary) via constructor argument . Temporary should still be used for form submissions, while permanent can be used for SEO purposes.

The need for this feature will be greater with the introduction of REST-style urls in 3.0.


Affects: 3.0 M1

Issue Links:

Referenced from: commits 5b12503

1 votes, 1 watchers

@spring-projects-issues
Copy link
Collaborator Author

Flyin Wolf commented

See http://jira.springframework.org/browse/SPR-6144 for an example that demonstrates how a @ResponseStatus( value=HttpStatus.CREATED ) annotation is ignored on a RedirectView. For this "Temporary/Permanent" status code, you would expect the annotation like below to work:

@RequestMapping(method = RequestMethod.POST)
@ResponseStatus( value=HttpStatus.SC_MOVED_PERMANENTLY )
public View doSomethingWithResource(
@ModelAttribute("resourceForm") ResourceForm resourceForm ) {

return new RedirectView( "/rest/resources/" + resourceId + ".html" ); // in real life, make this from a factory or something

}

@spring-projects-issues
Copy link
Collaborator Author

Arjen Poutsma commented

It's now possible to set a response status code explicitly with setResponseStatus on the RedirectView.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants