开发者

How can I access path variables in a URI template in the view (Spring 3/SpringMVC)?

开发者 https://www.devze.com 2022-12-09 05:54 出处:网络
I have a URI template in the form of \"/hotels/{hotel}/bookings/{booking}\", and can access the path variables in the controller via @PathVariable, but when building links in the view I need a referen

I have a URI template in the form of "/hotels/{hotel}/bookings/{booking}", and can access the path variables in the controller via @PathVariable, but when building links in the view I need a reference to the different path variables.

As an example, let's say the user requests "/hotels/123/bookings/booking-123", and in the view, there is a need to link back to the bookings listing "/hotels/123/bookings/". How do I get a hook to {hotel} from the URI template to generate the link? It seems clunky to inj开发者_如何学编程ect this into each view, is there a simpler way that I am missing?


This has been raised as a feature in Spring.

0

精彩评论

暂无评论...
验证码 换一张
取 消