configure following accordingly.
<mvc:resources mapping="/resources/**" location="/public-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?
해결책 2
configure following accordingly.
<mvc:resources mapping="/resources/**" location="/public-resources/"/>
다른 팁
Try to specify regex pattern for path vars:
@RequestMapping(value = "/{year:\\d+}/{month:\\d+}/**", method = RequestMethod.GET)
This helps spring to avoid conflicts with <mvc:resources/>
mapped to path like /images/**
. If your path variable can contain all except 'images' you can try regex like this: (?!images)
.
You may configure resource handlers for resource folders such as /images
.
It should help, because mapping of these handlers would be more specific than /{moduleName}/{subModuleName}
, therefore resource handlers should take precedence.