摘要: SpringBoot默认是以jar包的方式启动嵌入式的Servlet容易来启动SpringBoot的Web应用,没有web.xml文件 因此我们可以使用以下方式来注册Servlet、Filter、Listener。 (1)、注册Servlet (2)、注册Filter (3)、注册Listener 阅读全文
posted @ 2019-01-29 20:37 SpringCore 阅读(412) 评论(0) 推荐(0) 编辑
摘要: 第一种方式在配置文件中进行修改 第二种方式在配置类中进行修改 阅读全文
posted @ 2019-01-29 19:34 SpringCore 阅读(3204) 评论(0) 推荐(2) 编辑
摘要: (1)自定义异常处理&返回定制Json数据 缺点:没有自适应效果,只是会返回自定义的json数据 (2) 缺点:可以自适应页面(浏览器返回错误页面,客户端返回Json数据),但不会携带我们自定义数据 (3) 响应自适应,可以携带我们自定义的数据 阅读全文
posted @ 2019-01-26 20:28 SpringCore 阅读(1125) 评论(0) 推荐(0) 编辑
摘要: (1)有模板引擎的情况下,例如404错误,将会在thymeleaf的templates的error下寻找404.html,如果找不到再寻找4xx.html *所有4开头的错误状态码如果找不到特定的html页面将会指向4xx.html 页面可以获取到的信息 timestamp:时间戳 status:状 阅读全文
posted @ 2019-01-26 20:13 SpringCore 阅读(765) 评论(0) 推荐(0) 编辑
摘要: (1)配置HiddenHttpMethodFilter(SpringMVC需要配置,SpringBoot已经为我们自动配置了) (2)在视图页面创建一个Post Form表单,在表单中创建一个input项,type="hidden" name="_method",value属性值为请求方式 阅读全文
posted @ 2019-01-26 19:45 SpringCore 阅读(1986) 评论(0) 推荐(0) 编辑
摘要: (1)、编写拦截器 (2)、对拦截器进行注册 阅读全文
posted @ 2019-01-26 19:37 SpringCore 阅读(7833) 评论(0) 推荐(0) 编辑
摘要: (1)、编写国际化配置文件 在resources下新建i18n文件夹,并新建以下文件 ①index.properties 1 username=username ②index_en_US.properties 1 username=username ③index_zh_CN.properties 1 阅读全文
posted @ 2019-01-26 19:13 SpringCore 阅读(7288) 评论(0) 推荐(0) 编辑
摘要: SpringBoot中自动配置了 ViewResolver(视图解析器) ContentNegotiatingViewResolver(组合所有的视图解析器) 自动配置了静态资源文件夹、静态首页、favicon.ico及Webjars Converter(转换器,转换类型使用) Formatter( 阅读全文
posted @ 2019-01-26 17:34 SpringCore 阅读(808) 评论(0) 推荐(0) 编辑
摘要: (1)、添加pom依赖 * SpringBoot1.x 默认的thymeleaf版本低,如果要自定义版本,需要在pom properties 覆写SpringBoot默认的thymeleaf版本号 * SpringBoot2.x 无需此操作 (2)、将Html页面放至classpath:/templ 阅读全文
posted @ 2019-01-26 12:40 SpringCore 阅读(1580) 评论(0) 推荐(0) 编辑
摘要: 静态资源是指 》 CSS、JS之类的文件 首先创建SpringBoot Web项目 添加Spring Boot Web Starter 第一种方式(将静态资源文件放至静态资源文件夹) ① “/” 当前项目的根路径 ②classpath:/META-INF/resources/ ③classpath: 阅读全文
posted @ 2019-01-26 12:25 SpringCore 阅读(3494) 评论(0) 推荐(0) 编辑