Sanny Pathak
Sanny Pathak

Reputation: 45

What is the use of ; and .+ in GetMapping springboot

I am currently working on a project where one @GetMapping is making use of ;and +. Given below is the controller class code.

 @RestController @Produces(MediaType.APPLICATION_JSON)
 @RequestMapping("/v1") 
 public class RestServiceController {

 @GetMapping(path = "/{Id};{Time:.+}")   
 public ResponseEntity<Request> getSRequestById(@PathVariable String Id, @PathVariable String Time) {
 
  }
}

When I am Hitting the URL http://localhost:8080/v1/123. I am getting below warning org.springframework.web.servlet.PageNotFound - No mapping for GET /v1/123

Upvotes: 0

Views: 269

Answers (1)

PeterMmm
PeterMmm

Reputation: 24630

The mapping contains a regular expression (RE) .+, that means at least one character. The ; is a literal to separate the id from time.

Valid URL: /1108;11722222422, /AG8;TIME

Not valid URL: /123, /8;

Anyway, as long @PathVariable is mandatory (required=true by default) the RE is needless.

Upvotes: 4

Related Questions