![](/img/trans.png)
[英]How to set multiple base paths for Spring REST controllers (e.g. common base path for one or more packages)
[英]Spring 4: Multiple base path in one controller
I have a question about Spring 4. My controller is accessible from a URL, but I want to have a second URL where only the beginning is different to access the same endpoints of this controller.
這是我的 controller:
@RestController("MyController")
@RequestMapping(value={"/abc/def/ghi","/ijk/def/ghi"})
public class MyController {
// code continuation
但我收到此錯誤消息。
Multiple class level mappings defined on class com.MyController
我錯過了什么? 謝謝。
編輯:正如 M. Dudek 所說,確實有必要升級 Hateoas。
也許這個?
@RestController("MyController")
@RequestMapping(value={"/abc/def/ghi","/ijk/def/ghi"})
public class MyController {
// code continuation
@RequestMapping
有一個String[]
value
參數(不是values
),所以你應該能夠像這樣指定多個值:
@RequestMapping(value={"/abc/def/ghi"},{"/ijk/def/ghi"})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.