Spring MVC Request mapping, can this be dynamic/configurable?

前端 未结 5 818
慢半拍i
慢半拍i 2021-02-19 06:37

With Spring MVC, I know how you set the RequestMapping in every controller and method/action.

But what if I wanted this to be configurable, so for example I

5条回答
  •  无人共我
    2021-02-19 06:59

    Would this sort of URL mapping work for you?

    www.example.com/blog/1/
    www.example.com/blog/2/
    

    If yes, then that's easy: Spring 3 supports path variables: http://static.springsource.org/spring/docs/3.0.x/reference/mvc.html#mvc-ann-requestmapping-advanced

    Alternatively, you can create a generic request mapping and your own sub-dispatcher that reads a config file, but I think that's probably more work than it's worth.

提交回复
热议问题