我有一个遗留系统,其中使用简单的内部框架使用查询参数来确定请求的类/方法。例如
/endpoint?product=foo&action=bar&amount=1.0
/endpoint?product=foo&action=baz&amount=1.0
而且我想将产品的所有操作映射到一个类,以便可以大大简化管道,例如
@Controller
@RequestMapping("/endpoint/foo/**")
public class FooController {
@AutoWire
private FooProductService s; // one of many beans that have to be wired into lots of classes
@RequestMapping("/bar")
public void bar(@PathVariable String amount, Model model) {
// implementation omitted
}
@RequestMapping("/baz")
public void baz(@PathVariable String amount, Model model) {
// implementation omitted
}
}
这是一个已发布的 API,因此我们无法更改公共 API -> URL 无法更改。
我认为也许这可以使用配置来完成,作为方面,甚至是没有自己注释的自定义框架。