Skip to content

Combine @PathParam with @RequestBody [SPR-14149] #18721

Closed
@spring-projects-issues

Description

@spring-projects-issues

Suresh opened SPR-14149 and commented

xpI am using spring boot as RESTFul service. I have a requirement to combine @PathParam value with @RequestBody POJO.

The reason is, I am using hibernate validator to validate the POJO. I can manually merge @PathParam values in Controller class but the hibernate validator is called before the merge happens.

*Example:
I have a POJO as defined below.

public Class User{
  private String id;
  private String name;
  private String firstName;
....
}

Resource class as defined below:

@RestController
@RequestMapping(value = "user")
public Class UserResource{

  @RequestMapping(value = "{id}", method = RequestMethod.PUT)
  public String update(@PathVariable String id, @RequestBody @Validated(UpdateValidator.class) User user){
    user.setId(id);// Have to avoid this.
    service.update(user);
  }
}

No further details from SPR-14149

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: declinedA suggestion or change that we don't feel we should currently applytype: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions