且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Spring 4 MVC中是否可以将控制器/具有控制器作为内部类嵌套?

更新时间:2023-02-12 09:58:07

将类层次结构与资源层次结构联系起来并不是这里的主要设计驱动力.

Tying your class hierarchy to your resource hierarchy should not be the main design driver here.

在Spring MVC中,控制器是简单的POJO,使其易于测试,组合优于继承,注解用于传达含义并使代码更具可读性.

IN Spring MVC, Controllers are simple POJOs to make them easy to test, composition is favored over inheritance, annotations are used to convey meaning and make your code more readable.

在控制器"下嵌套控制器会破坏这些目标中的几个目标.

Nesting Controllers under Controllers defeats several of those goals.