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

Automatically expose @PathVariables in the Model [SPR-7543] #12200

Closed
spring-issuemaster opened this issue Sep 11, 2010 · 5 comments
Closed

Automatically expose @PathVariables in the Model [SPR-7543] #12200

spring-issuemaster opened this issue Sep 11, 2010 · 5 comments
Assignees
Milestone

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Sep 11, 2010

Keith Donald opened SPR-7543 and commented

It'd be nice instead of having to do this:

@RequestMapping(value="/edit/{slug}", method=RequestMethod.GET)
public String getEditAppForm(@PathVariable String slug, Account account, Model model) {
    model.addAttribute(connectedAppRepository.getAppForm(account.getId(), slug));
    model.addAttribute("slug", slug);
    return "develop/apps/edit";
}

... and using ${slug} in my template to access the @PathVariable value, I could simply do:

@RequestMapping(value="/edit/{slug}", method=RequestMethod.GET)
public String getEditAppForm(@PathVariable String slug, Account account, Model model) {
    model.addAttribute(connectedAppRepository.getAppForm(account.getId(), slug));
    return "develop/apps/edit";
}

and reference something automatically exposed like ${pathVars.slug} in my template.


Affects: 3.0.4

Issue Links:

  • #11152 Access URI template variables in view ("duplicates")
  • #13391 Need a way to disable behavior added in "Automatically expose @PathVariables in the Model" SPR-7543
  • #13130 Use AbstractView instead of HandlerMethodArgumentResolver to add @PathVariable values to the model

Referenced from: commits ed9d9a4

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jan 24, 2011

Ted Young commented

For anyone interested in this functionality now, I wrote an example of how you can implement it as an aspect (and disable it when 3.1 is released).

http://tedyoung.me/2011/01/24/spring-expose-pathvariables-to-the-model/

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Apr 26, 2011

Rossen Stoyanchev commented

Resolved @PathVariable method argument values are now added to the model.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Apr 26, 2011

Rossen Stoyanchev commented

Note that this change is implemented on the new HandlerMethod-based HandlerMapping and HandlerAdapter pair (see #12864) that is enabled by default in the Spring MVC namespace.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Oct 7, 2011

Craig commented

Requested a way to disable this new behavior in #13391

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Nov 29, 2011

Rossen Stoyanchev commented

See #13130 for additional refinements to the implementation of this feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.