thymeleaf-spring icon indicating copy to clipboard operation
thymeleaf-spring copied to clipboard

Add support full class name for #mvc.url

Open TorosyanV opened this issue 4 years ago • 2 comments

Example I have 2 controllers with names AccountController and AuthorController

  • for first one mapping will be ${#mvc.url('AC#getAll').build()}
  • for second one mapping will be ${#mvc.url('AC#getAll').build()}

they are same and will get java.lang.IllegalArgumentException: No unique match for mapping AC#getAll:

And where is no possibility to use some qualifier or full controller name. Example I can use for mappings like ${#mvc.url('AccountController#getAll').build()} but now I'm getting java.lang.IllegalArgumentException: Mapping not found: AccountController#getAll

Please add support to use full controller name

If somebody think this is useful please vote

TorosyanV avatar Jun 11 '20 17:06 TorosyanV

Very useful. I got this error a couple minutes ago and realize that I had two methods with the same name and had to change one of them, even one being a get and the other being a post.

anti-duhring avatar Jan 26 '23 01:01 anti-duhring

It's an issue with Spring MVC and not Thymeleaf.

The name is generated by org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMethodMappingNamingStrategy. You can override the name it produces by giving your mapping a name specifically.

@Controller
class MyController {
    @GetMapping("/", name="MyController") // Generates 'MyController#index'
    fun index() = "index"
}

btegenbosch avatar Nov 29 '23 13:11 btegenbosch