Search code examples
spring-mvcresourcesconflictpath-variables

SpringMVC conflict by @PathVariable and resources


I have a problem while use Spring MVC:

I wrote a Controller, a method named

@RequestMapping("/{moduleName}/{subModuleName}")
public ModelAndView getModuleContent(@PathVariable String moduleName, @PathVariable String subModuleName) {
     ...
}
,

now the problem is, when I access a static resource, for example:

http://www.mytomcat:8080/images/testpng


it would mapping that controller, but I don't want this, how can I resolve the conflict?


Solution

  • configure following accordingly.

    <mvc:resources mapping="/resources/**" location="/public-resources/"/>