Spring MVC的文档有时会提到处理程序"或请求处理程序".例如, docs.spring.io/autorepo/docs/spring/4.0.4.RELEASE/javadoc-api/org/springframework/web/servlet/handler/SimpleUrlHandlerMapping.html 说:
The documentation of Spring MVC sometimes says about "handlers" or "request handlers". For instance, docs.spring.io/autorepo/docs/spring/4.0.4.RELEASE/javadoc-api/org/springframework/web/servlet/handler/SimpleUrlHandlerMapping.html says:
HandlerMapping接口的实现,以从URL映射到请求处理程序bean
Implementation of the HandlerMapping interface to map from URLs to request handler beans
有时它还涉及到控制器.例如,有一个名为org.springframework.web.servlet.mvc.Controller的接口( docs.spring.io/spring-framework/docs/2.5.x/api/org/springframework/web/servlet/mvc/Controller .html ).
And sometimes it says about controllers. For instance, there is an interface called org.springframework.web.servlet.mvc.Controller ( docs.spring.io/spring-framework/docs/2.5.x/api/org/springframework/web/servlet/mvc/Controller.html ).
我的问题是:控制器和处理程序是否相同?
My question is: are Controllers and Handlers the same?
推荐答案通常来说,控制器是处理程序,但处理程序不必一定是控制器.
Generally speaking, a Controller is Handler, but a Handler doesn't have to be a Controller.
例如,HttpRequestHandler,WebRequestHandler,MessageHandler都是可以与DispatcherServlet一起使用的处理程序. ((@)Controller是用于执行Web请求并返回视图的处理程序.)
For example, HttpRequestHandler, WebRequestHandler, MessageHandler are all handlers which can work with the DispatcherServlet. ( (@)Controller is a handler for executing a web request and returning a view.)
简短地说,Handler只是一个术语,它既不是类也不是接口.并且负责执行映射.
Shortly, Handler is just a term, it is neither a class nor interface. And it is responsible for executing the Mapping.
更多推荐
Spring MVC中的Controller和Handler之间有什么区别?
发布评论