简体   繁体   中英

Using dropwizard to make RESTful service, the URL can contain a space

I have some code making a @Path for an endpoint:

@Path("/productLine:[a-zA-Z]{1,25}}/cat")

I want to allow two word product lines in the URL. I tried this

@Path("productLine:[a-zA-Z ]{1,25}}/cat")

But the client returns a

HTTP 404 Not Found

when I use a request that has two words, like this:

/services/New Host/cat

您可以尝试:

@Path("productLine:[a-zA-Z\x0B]{1,25}}/cat")

This worked:

@Path("productLine:[a-zA-Z%20]{1,25}}/cat")

The %20 is the HTTP encoding for space.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM