简体   繁体   中英

how can I pass parameter with slash as the PathParam in rest API

I build a rest API like www.example.com/checking/{id} and it works well. But when I passed in a id with slash, like abc/123, then the API path becomes the www.example.com/checking/abc/123 which actually breaks the path.

I can use the encoded URL id, like abc/123 encoded as abc%2F123, but it seems like when I use it to hit my API, it is hanging there, I can not find something in the log.

Is there any suggestion so that I can do this ? Is it a tomcat configuration issue or coding issue ?

Thanks,

您必须在路径中使用正则表达式,如下所示:

@Path("{name:.+}")

Use the solutions posted in this tread and solve the problem.

Receive an HTTP 400 error if %2F is part of the GET URL in JBOSS

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