本文介绍了RestEasy @Path问题与正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以使用可选路径变量定义路径。
Is it possible to define path with optional path variables.
如下面的uri:
/应用程序/令/ {使} /模型/ {模型} /年/ {年} /里程/ {里程} / fuelType / {fuelType} / maxPrice / {maxprice} /传输/ {传输} / engineSize / {engineSize}
/app/make/{make}/model/{model}/year/{year}/mileage/{mileage}/fuelType/{fuelType}/maxPrice/{maxprice}/transmission/{transmission}/engineSize/{engineSize}
URI可以由任何0个或多个参数组合组成?有没有办法告诉resteasy所有这些路径都是可选的?
URI may be composed of any 0 or more combinations of the parameters? Is there a way to tell resteasy that all those paths are optional?
欢呼。
推荐答案
@Path("/make/{make}{model:(/model/[^/]+)?}{fuel : (/fuel/[^/]+)?}{gearbox : (/gearbox/[^/]+)?}/cars")
app/{make:(/make/[^/]+)?}{model:(/model/[^/]+)?}{year:(/year/[^/]+)?}{mileage:(/mileage/[^/]+)?}
我想出了上面的解决方法,但是在方法中我需要删除路径名。
I came up with the above workaround which works but inside the method I need to remove the pathname.
这篇关于RestEasy @Path问题与正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!