Skip to content

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

@spring-projects-issues

Description

@spring-projects-issues

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:

Referenced from: commits ed9d9a4

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions