One of the successful implementation is Java Spring MVC. In Spring, if you want a class to be a controller you can use the annotation @RestController for this class. And in this class, use annotation @RequestMapping to show this is an RESTful API function.
HTTP报文如何解析到Controller方法?
Spring MVC框架的底层是Servlet。Servlet是一个标准,主要规定了处理请求与响应的service接口,在service接口中只需要实现业务逻辑即可。而Servlet由Servlet容器负责管理与运行,常见的Servlet容器有Tomcat,Jetty等。以Tomcat中的Servlet接口定义为例,如下所示:
/** * Initializes the <tt>Discovery Client</tt> with the given configuration. * * @param config * the instance info configuration that will be used for * registration with Eureka. * @param eurekaConfig the eureka client configuration of the instance. */ publicvoidinitComponent(EurekaInstanceConfig config, EurekaClientConfig eurekaConfig, AbstractDiscoveryClientOptionalArgs args){ this.eurekaInstanceConfig = config; this.eurekaClientConfig = eurekaConfig; if (ApplicationInfoManager.getInstance().getInfo() == null) { // Initialize application info ApplicationInfoManager.getInstance().initComponent(config); } InstanceInfo info = ApplicationInfoManager.getInstance().getInfo(); ...... }
评论
shortname
for Disqus. Please set it in_config.yml
.