Spring mvc与springboot

 

org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration:

 

viewResolver

 

 

 

类路径文件

把类路径下面的/static,/public,/resources和/META_INF/resource文件夹下的静态文件直接映射为/**,可通过http://localhost:8080/**来访问

 

 

 

只要我们定义了Converter,GenericConverter和Formatter接口的实现Bean,这些Bean就会自动注册到SpringMVC中。

 

 

 

转载messageConverters:https://www.jianshu.com/p/2f633cb817f5

 

 

 

感觉是根据support先找argumentResolver和returnResolover 然后便利所有的messageConvertType 找mediaType相符的,或者其他逻辑:

 

静态首页支持

把静态index.html文件放置在如下目录:

classpath:/META-INF/resource/index.html

classpath:/resources/index.html

classpath:/static/index.html

classpath:/public/index.html

 

意外收获:

 

原来框架里注入userId是这么注入的

 

但是始终没有找到当我什么注解都不加的时候用的什么resolver??

继续学习:

https://www.jianshu.com/p/f4653fe8c935

还是没有结论那就调试吧:

写个简单的用例: 

 

来吧:

在org.springframework.web.method.support.HandlerMethodArgumentResolverComposite#getArgumentResolver打个断点:

 

在遍历若干个resolver之后,终于抓了出来org.springframework.web.servlet.mvc.method.annotation.ServletModelAttributeMethodProcessor

 

看看其父类:

 

好啦,真相大白

再看看所谓的基本类型会是什么

 

答案:org.springframework.web.method.annotation.RequestParamMethodArgumentResolver

 

posted @ 2020-09-03 22:58  l2c  阅读(135)  评论(0)    收藏  举报