簡體   English   中英

Spring 4:多條基本路徑在一個 controller

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM