[英]Best practice to keep method visibility with Spring @Controller stereotype
My project at current job use private access modifier for methods of MVC controllers: 我当前作业的项目使用私有访问修饰符来处理MVC控制器的方法:
@Controller
public class HelloWorldController {
@RequestMapping("/helloWorld")
private ModelAndView helloWorld() {
I have integrated PMD and his report has a lot of: 我已经集成了PMD,他的报告有很多:
/src/main/java/com/web/controller/SignalController.java:91: Avoid unused private
methods such as 'handleNewRequest()'.
So instead of disabling useful PMD rule I think to change controller's methods visibility to public . 因此,我认为将控制器的方法可见性更改为公共,而不是禁用有用的PMD规则。
Are there any reasons to keep controller's methods private ? 是否有任何理由将控制器的方法保密 ?
You're shooting yourself in the foot by making it private: 你将自己私有化,从而使自己陷入困境:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.