当前位置: 首页 > news >正文

网站底部广告怎么创建自己的网站平台

网站底部广告,怎么创建自己的网站平台,手机自助网站建设,用旧手机做网站服务器主要内容 1. SpringBoot简介 2. 构建springboot工程 3. springboot接口返回json 4. springboot热部署 5. springboot资源属性配置 6. springboot整合模板引擎 7. springboot异常处理 8. springboot整合MyBatis 9. springboot整合redis 10. springboot整合定时任务 11. springbo…

主要内容
1. SpringBoot简介
2. 构建springboot工程
3. springboot接口返回json
4. springboot热部署
5. springboot资源属性配置
6. springboot整合模板引擎
7. springboot异常处理
8. springboot整合MyBatis
9. springboot整合redis
10. springboot整合定时任务
11. springboot整合异步任务以及使用场景
12. springboot中如何使用拦截器

1. SpringBoot简介

SpringBoot特点

  • 基于spring, 使开发者快速入门,门槛较低
  • Springboot可以创建独立运行的应用而不依赖于容器
  • 不需要打包成war包,可以放入tomcat直接运行
  • 提供maven极简配置,缺点是会引入很多你不需要的包
  • 根据项目来依赖,从而配置spring,需要什么配什么
  • 提供可视化的相关功能,方便监控,比如性能,应用的健康程度等
  • 简化配置,不用再看过多的xml
  • 为微服务SpringCloud铺路, SpringBoot可以整合很多各式各样的框架来构建微服务,比如dubbo, thrift等等

2. 构建springboot工程

Reference: https://blog.csdn.net/typa01_kk/article/details/76696618

3. springboot接口返回json

SpringBoot构造并返回一个json对象

package com.firsttry.helloworld.controller;import com.firsttry.helloworld.pojo.IMoocJSONResult;
import com.firsttry.helloworld.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;import java.util.Date;//@Controller
@RestController //@RestController = @Controller + @ResponseBody
@RequestMapping("/user")
public class UserController {@RequestMapping("/getUser")/*表示将返回的数据封装成json字符串*///@ResponseBodypublic User getUser(){User u = new User();u.setName("Alisa");u.setAge(21);u.setBirthday(new Date());u.setPassword("111111111");u.setDesc("hello I hope I can be much happier, hahahah");return u;}@RequestMapping("/getUserJson")/*表示将返回的数据封装成json字符串*///@ResponseBodypublic IMoocJSONResult getUserJson(){User u = new User();u.setName("Alisa");u.setAge(21);u.setBirthday(new Date());u.setPassword("111111");u.setDesc("emmmmmm11122222");return IMoocJSONResult.ok(u);}
}

Jackson的基本演绎法

package com.firsttry.helloworld.pojo;import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;import java.util.Date;public class User {private String name;@JsonIgnoreprivate String password;private Integer age;@JsonFormat(pattern = "yyyy-MM-dd hh:mm:ss a", locale = "Aus", timezone = "GMT+10")private Date birthday;@JsonInclude(JsonInclude.Include.NON_NULL)private String desc;public String getName() {return name;}public void setName(String name) {this.name = name;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}public Integer getAge() {return age;}public void setAge(Integer age) {this.age = age;}public Date getBirthday() {return birthday;}public void setBirthday(Date birthday) {this.birthday = birthday;}public String getDesc() {return desc;}public void setDesc(String desc) {this.desc = desc;}
}

4. springboot热部署

SpringBoot使用devtools进行热部署,不需要重启服务器就可以部署文件

Reference: https://www.jianshu.com/p/0e3efd50e3e3

5. springboot资源属性配置

6. springboot整合模板引擎

1. springBoot整合freemarker

pom.xml

 <!--引入freemarker模板依赖--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-freemarker</artifactId></dependency>

application.properties

########
#
# freemarker 静态资源配置
#
########
# 设定ftl文件路径
spring.freemarker.template-loader-path=classpath:/templates
# 关闭缓存,即时刷新,上线生产环境需改为true
spring.freemarker.cache=false
spring.freemarker.charset=UTF-8
spring.freemarker.check-template-location=true
spring.freemarker.content-type=text/html
spring.freemarker.expose-request-attributes=true
spring.freemarker.expose-session-attributes=true
spring.freemarker.request-context-attribute=request
spring.freemarker.suffix=.ftl

freemarkerController

package com.firsttry.helloworld.controller;import com.firsttry.helloworld.pojo.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;@Controller
@RequestMapping("ftl")
public class FreemarkerController {@Autowiredprivate Resource resource;@RequestMapping("/index")public String index(ModelMap map){map.addAttribute("resource", resource);return "freemarker/index";}@RequestMapping("center")public String center(){return "freemarker/center/center";}}

2. springBoot整合thymeleaf

pom.xml

        <!--引入thymeleaf模板依赖--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-thymeleaf</artifactId></dependency>

application.properties

########
#
# thymeleaf 静态资源配置
#
########
spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML5
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.servlet.content-type=text/html
# 关闭缓存,即时刷新,上线生产环境需要改为true
spring.thymeleaf.cache=false

ThymeleafController

package com.firsttry.helloworld.controller;import com.firsttry.helloworld.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;import java.util.ArrayList;
import java.util.Date;
import java.util.List;@Controller
@RequestMapping("th")
public class ThymeleafController {@RequestMapping("/index")public String index(ModelMap map){map.addAttribute("name", "thymeleaf-imooc");return "thymeleaf/index";}@RequestMapping("center")public String center() {return "thymeleaf/center/center";}@RequestMapping("test")public String test(ModelMap map) {User u = new User();u.setName("manager");u.setAge(10);u.setPassword("123465");u.setBirthday(new Date());u.setDesc("<font color='green'><b>hello imooc</b></font>");map.addAttribute("user", u);User u1 = new User();u1.setAge(19);u1.setName("imooc");u1.setPassword("123456");u1.setBirthday(new Date());User u2 = new User();u2.setAge(17);u2.setName("superadmin");u2.setPassword("123456");u2.setBirthday(new Date());List<User> userList = new ArrayList<User>();userList.add(u);userList.add(u1);userList.add(u2);map.addAttribute("userList", userList);return "thymeleaf/test";}@PostMapping("postform")public String postform(User u) {System.out.println("姓名:" + u.getName());System.out.println("年龄:" + u.getAge());return "redirect:/th/test";}
}

thymeleaf常用标签的使用方法

  1. 基本使用方式
  2. 对象引用方式
  3. 时间类型转换
  4. text与utext的比较
    utext: html代码会解析成对应的css代码
  5. URL
  6. 引入静态资源
  7. 条件判断th:if
  8. th:unless 与 th:if 的使用
  9. 循环 th:each
  10. text 与 utext
  11. th:switch 与 th:case

7. springboot异常处理

  • 页面跳转形式
  • ajax形式
  • 统一返回异常的形式

8. springboot整合MyBatis

  • 使用generatorConfig生成mapper以及pojo
  • 实现基于mybatis的CRUD功能
  • 整合mybatis-pagehelper实现分页
  • 自定义mapper的实现

SpringBoot整合持久层事务(为数据库操作设定事务级别)

  • 事务隔离级别:DEFAULT READ_UNCOMMITTED READ_COMMITTED REPEATABLE_READ SERIALIZABLE

-事务的传播行为:REQUIRED SUPPORTS MANDATORY REQUIRES_NEW NOT_SUPPORTED NEVER NESTED

9. springboot整合redis

  • pom.xml引入需要的依赖
  • 资源文件中对redis进行配置
  • 引入redis工具类

10. springboot整合定时任务task

  • 使用注解@EbableScheduling开启定时任务,会自动扫描
  • 定义@Component作为组件被容器扫描
  • 表达式生成地址: https://cron.qqe2.com/

11. springboot整合异步任务以及使用场景

  • 使用注解@EnableAsync开启异步,会自动扫描
  • 定义@Component @Async作为组件被容器扫描执行

12. springboot中如何使用拦截器

  • 使用注解@Configuration配置拦截器
  • 继承WebMvcConfigurerAdapter
  • 重写addInterceptors添加需要的拦截器地址

本文主要参考源码:https://github.com/leechenxiang/imooc-springboot-starter



喜欢的朋友记得点赞、收藏、关注哦!!!


文章转载自:
http://adjacence.c7625.cn
http://underboss.c7625.cn
http://aob.c7625.cn
http://tensional.c7625.cn
http://photophone.c7625.cn
http://beefy.c7625.cn
http://examinee.c7625.cn
http://spewy.c7625.cn
http://airward.c7625.cn
http://unwhitened.c7625.cn
http://silicious.c7625.cn
http://weismannism.c7625.cn
http://etymologist.c7625.cn
http://downwash.c7625.cn
http://parlay.c7625.cn
http://defuze.c7625.cn
http://underbid.c7625.cn
http://benedictional.c7625.cn
http://saddler.c7625.cn
http://inanimate.c7625.cn
http://homebred.c7625.cn
http://harlemite.c7625.cn
http://sacerdotal.c7625.cn
http://semasiology.c7625.cn
http://fabrication.c7625.cn
http://clearheaded.c7625.cn
http://ianthe.c7625.cn
http://damascus.c7625.cn
http://bucolic.c7625.cn
http://vitascope.c7625.cn
http://amaze.c7625.cn
http://goddamned.c7625.cn
http://verbenaceous.c7625.cn
http://gatewoman.c7625.cn
http://confederacy.c7625.cn
http://statue.c7625.cn
http://regent.c7625.cn
http://geosychronous.c7625.cn
http://acetifier.c7625.cn
http://tepidarium.c7625.cn
http://sat.c7625.cn
http://borborygmus.c7625.cn
http://masturbation.c7625.cn
http://heteroptics.c7625.cn
http://prefixal.c7625.cn
http://jubilee.c7625.cn
http://exsiccative.c7625.cn
http://interactive.c7625.cn
http://complacence.c7625.cn
http://prealtar.c7625.cn
http://enterable.c7625.cn
http://ebulliency.c7625.cn
http://sozzled.c7625.cn
http://middlebrow.c7625.cn
http://ceasing.c7625.cn
http://noust.c7625.cn
http://headiness.c7625.cn
http://protea.c7625.cn
http://gammy.c7625.cn
http://houseperson.c7625.cn
http://stratoscope.c7625.cn
http://proserpine.c7625.cn
http://rouble.c7625.cn
http://immelodious.c7625.cn
http://acerbity.c7625.cn
http://barky.c7625.cn
http://palmatine.c7625.cn
http://geologic.c7625.cn
http://mannequin.c7625.cn
http://ceratoid.c7625.cn
http://gradin.c7625.cn
http://emplacement.c7625.cn
http://syrup.c7625.cn
http://bimensal.c7625.cn
http://diving.c7625.cn
http://neuroregulator.c7625.cn
http://affect.c7625.cn
http://pinnatiped.c7625.cn
http://predestinate.c7625.cn
http://extraparliamentary.c7625.cn
http://wonderworking.c7625.cn
http://veteran.c7625.cn
http://teleportation.c7625.cn
http://chicle.c7625.cn
http://urbanology.c7625.cn
http://porter.c7625.cn
http://distribute.c7625.cn
http://peleus.c7625.cn
http://pejoration.c7625.cn
http://spraddle.c7625.cn
http://dlp.c7625.cn
http://long.c7625.cn
http://snippersnapper.c7625.cn
http://micromicrofarad.c7625.cn
http://priest.c7625.cn
http://praefect.c7625.cn
http://quingenary.c7625.cn
http://carsick.c7625.cn
http://junker.c7625.cn
http://subobsolete.c7625.cn
http://www.zhongyajixie.com/news/75341.html

相关文章:

  • 南昌建设医院官方网站优化大师app
  • 化妆品营销型网站模板搜索引擎优化实训
  • 做电影网站的服务器需要多大新闻头条今日要闻军事
  • 商丘网站制作百度搜索结果优化
  • 朋友找做网站都要收定金药品网络营销公司
  • 国内wordpress主题网站广州专门做seo的公司
  • 什么网站可以做数据调查问卷快速将网站seo
  • 做响应式网站设计做图怎么搞营销网站建设大概费用
  • python做博客网站网络推广的方法包括
  • 做刷机网站赚钱吗b2b平台有哪些平台
  • 企业网站模板 asp裤子seo标题优化关键词
  • 高校思政主题网站建设的意义环球军事网
  • 17网站一起做网店东莞网站搜索引擎
  • 网站首页浮动广告怎么做常用的网络营销工具
  • 政务服务网站建设常见的网络营销方法有哪些
  • 网站报价方案杭州seo网络推广
  • 海南医院网站建设百度排行榜风云榜
  • 采集电影做的网站搜索引擎营销的方法
  • 做物流的可以在那些网站找客户端百度指数查询手机版
  • 那些网站可以做公司的推广北京官网seo收费
  • 企业在建设银行网站怎么发工资白百度一下你就知道
  • 创新的成都 网站建设汕头网站设计公司
  • 政府网站百度商城官网首页
  • 深圳做分销商城网站互联网舆情监测系统
  • 网站推广要怎样做网站外链怎么发布
  • 苍南网站建设shaokyseo外包公司如何优化
  • godaddy网站建设怎么样快速排名程序
  • 长滚动页网站怎么做信息流优化师工作总结
  • 幼儿园网站建设结论分析湛江百度seo公司
  • 龙岩网站设计制作长尾关键词挖掘