Home > Software engineering >  Spring 4: Multiple base path in one controller
Spring 4: Multiple base path in one controller

Time:12-21

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.

Here is my controller:

@RestController("MyController")
@RequestMapping(value={"/abc/def/ghi","/ijk/def/ghi"})
public class MyController {
// code continuation

But I get this error message.

Multiple class level mappings defined on class com.MyController

Did I miss something? Thanks.

Edit : as M. Dudek mentioned, it was indeed necessary to upgrade Hateoas.

CodePudding user response:

@RequestMapping has a String[] value parameter (not values), so you should be able to specify multiple values like this:

@RequestMapping(value={"/abc/def/ghi"},{"/ijk/def/ghi"})

CodePudding user response:

maybe this?

@RestController("MyController")
@RequestMapping(value={"/abc/def/ghi","/ijk/def/ghi"})
public class MyController {
// code continuation
  • Related