zhoujunlin's blog

莫道君行早, 更有早行人.

08-MVC处理流程

MVC处理流程

当浏览器发送一个http://127.0.0.1:8080/hello到达服务器后, 其处理流程如下: 服务器提供了一个DispatcherServlet, 继承自HttpServlet提供了标准的servlet技术. 路径: 默认映射路径为: / , 即会匹配所有请求路径, 可作为请求的统一入口. 也被称为前控制器. jsp不会匹配到DispatcherSe...

07-HandlerMapping和HandlerAdapter

HandlerMapping和HandlerAdapter

BeanNameUrlHandlerMapping @Configuration public class WebConfig01 { @Bean public TomcatServletWebServerFactory tomcatServletWebServerFactory() { return new TomcatServletWebServer...

06-异常处理

异常处理

Spring 局部异常处理器-json static class Controller1 { public void foo() { } @ExceptionHandler @ResponseBody public Map<String, Object> handle1(ArithmeticException arithmeticE...

05-MessageConverter和ControllerAdvice

MessageConverter和ControllerAdvice

准备对象 @Data static class User { private String name; private int age; @JsonCreator // 默认jackson会使用无参构造器反序列化 这里强制使用当前带参构造器 public User(@JsonProperty("name") String name, @JsonProp...

04-返回值处理器

返回值处理器HandlerMethodReturnValueHandlerComposite

准备对象 @Data @NoArgsConstructor @AllArgsConstructor public class User { private String name; private int age; } 准备FreeMarker视图解析器 @Configuration public class WebConfig { @Bean publi...

01-进程与线程

进程与线程

1.1 概念 进程 程序由指令和数据组成,但这些指令要运行,数据要读写,就必须将指令加载到CPU,数据加载到内存。在指令运行过程中还需要用到磁盘、网络等设备。进程就是用来加载指令、管理内存、管理IO的。 当一个程序被运行,从磁盘加载这个程序的代码至内存,这时就开启了一个进程。 进程就可以视为一个程序的实例。大部分程序可以同时运行多个实例进程(例如记事本、画图、浏览器等),也有的...

03-MVC执行流程-参数解析与Model

MVC执行流程

重要组件 准备Model,Controller @Configuration public class WebConfig { @ControllerAdvice static class MyControllerAdvice { @ModelAttribute("b") public String bar() { ...

02-参数解析器

认识各种入参ArgumentResolver

上一节通过调用方法获取了Spring提供的参数解析器,这节通过案例测试这些参数解析器的工作方式。 MyRequestMappingHandlerAdapter handlerAdapter = applicationContext.getBean(MyRequestMappingHandlerAdapter.class); handlerAdapter.getArgumentResolve...

01-DispatchServlet和RequestMapping

认识DispatchServlet和RequestMapping

SpringMVC启动 server.port=8090 spring.mvc.servlet.load-on-startup=1 @Configuration @ComponentScan // 引入配置 @PropertySource("classpath:application.properties") @EnableConfigurationProperties({Server...

02-ApplicationContext

认识ApplicationContext

ApplicationContext具备的能力 路径解析 ConfigurableApplicationContext applicationContext = SpringApplication.run(ApplicationContextTest01.class, args); /** * ResourcePatternResolver * classpath*: 可以加载...