上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 23 下一页
摘要: 导入thymeleaf依赖 hello.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> hello </body> </html> Hell 阅读全文
posted @ 2020-08-05 20:56 柒丶月 阅读(68) 评论(0) 推荐(0) 编辑
摘要: Servlet @WebServlet(urlPatterns = "/myservlet") public class MyServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, Ht 阅读全文
posted @ 2020-08-05 20:55 柒丶月 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 两个类 CommandLineRunner ApplicationRunner 1. CommandLineRunner @Component @Order(99) //数字越小,优先级越大,默认情况下,优先级的值为Integer.MAX_VALUE,表示优先级最低 public class MyC 阅读全文
posted @ 2020-08-05 20:52 柒丶月 阅读(100) 评论(0) 推荐(0) 编辑
摘要: 定义拦截器 public class MyInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse re 阅读全文
posted @ 2020-08-05 20:50 柒丶月 阅读(70) 评论(0) 推荐(0) 编辑
摘要: 同源策略 很多人对跨域有一种误解,以为这是前端的事,和后端没关系,其实不是这样的,说到跨域,就不得不说说浏览器的同源策略。 同源策略是由Netscape提出的一个著名的安全策略,它是浏览器最核心也最基本的安全功能,现在所有支持JavaScript的浏览器都会使用这个策略。所谓同源是指协议、域名以及端 阅读全文
posted @ 2020-08-05 20:49 柒丶月 阅读(92) 评论(0) 推荐(0) 编辑
摘要: 在 SpringBoot 项目中 ,异常统一处理,可以使用 Spring 中 @ControllerAdvice 来统一处理,也可以自己来定义异常处理方案。SpringBoot 中,对异常的处理有一些默认的策略,我们分别来看。 默认情况下,SpringBoot 中的异常页面 是这样的: 我们从这个异 阅读全文
posted @ 2020-08-05 20:47 柒丶月 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 1. 处理全局异常 @ControllerAdvice public class MyCustomException { @ExceptionHandler(MaxUploadSizeExceededException.class) public void myexception(MaxUpload 阅读全文
posted @ 2020-08-05 20:44 柒丶月 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 在application.properties 限制文件属性 表单上传 spring.servlet.multipart.max-file-size=1KB <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta na 阅读全文
posted @ 2020-08-05 20:42 柒丶月 阅读(69) 评论(0) 推荐(0) 编辑
摘要: 默认策略 SpringBoot 中对于SpringMVC的自动化配置都在WebMVCAutoConfiguration类中。在WebMvcAutoConfiguration类中有一个静态内部类WebMvcAutoConfigurationAdapter,实现了WebMvcConfigurer接口。W 阅读全文
posted @ 2020-08-05 20:39 柒丶月 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 默认实现 Json是目前主流的前后端数据传输方式,SptringMVC中使用消息转换器HttpMessageConverter对JSON的转换提供了很好的支持,在SpringBoot中更进一步,对相关的配置做了简化。默认情况下,当开发者新创建一个SpringBoot项目后,添加web依赖,这个依赖默 阅读全文
posted @ 2020-08-05 20:14 柒丶月 阅读(922) 评论(0) 推荐(1) 编辑
上一页 1 ··· 10 11 12 13 14 15 16 17 18 ··· 23 下一页