zoukankan      html  css  js  c++  java
  • SpringBoot(二)

    空气质量检测的一个小案例:

    (1)创建数据库

           

    (2)引入各种需要的依赖或者xml文件

          

              yml文件:

       

    server:
    port: 8080
    spring:
    jackson:
    date-format: yyyy-MM-dd HH:mm:ss
    time-zone: GMT+8
    thymeleaf:
    prefix: classpath:/templates/
    mode: HTML5
    cache: false
    datasource:
    name: test
    url: jdbc:mysql://localhost:3306/air
    username: root
    password:
    type: com.alibaba.druid.pool.DruidDataSource
    driver-class-name: com.mysql.jdbc.Driver
    filters: stat
    maxActive: 20
    initialSize: 1
    maxWait: 60000
    minIdle: 1
    timeBetweenEvictionRunsMillis: 60000
    minEvictableIdleTimeMillis: 300000
    validationQuery: select 'x'
    testWhileIdle: true
    testOnBorrow: false
    testOnReturn: false
    poolPreparedStatements: true
    maxOpenPreparedStatements: 20

    mybatis:
    mapper-locations: classpath:mapping/*.xml
    type-aliases-package: com.wp.entity
    (3)创建包

    @Controller
    public class AirController {
    @Resource(name="airService")
    private IAirService iAirService;

    @RequestMapping("/main")
    public String main(){
    return "main";
    }


    //查询所有
    @RequestMapping("/allair")
    @ResponseBody
    public Object allair(Model model) throws Exception {
    List<Air> list = iAirService.allair();
    return list;
    }


    //根据区域查询所在区域的所有检测记录
    @RequestMapping("/disair")
    @ResponseBody
    public Object airbydis(Model model,String district) throws Exception {
    List<Air> list = iAirService.airbydis(district);
    return list;
    }


    //添加的页面
    @RequestMapping("/add")
    public String add(){
    return "addAir";
    }

    //添加检测数据
    public String addair(Air air) throws Exception {
    int addair = iAirService.addair(air);
    if (addair>0){
    return "main";
    }else {
    return "addAir";
    }
    }


    主页的ajax:

    效果图:

    模糊查询:

    点击添加:

    点击提交后跳转到首页

    
    
  • 相关阅读:
    学习进度条第十周
    学习进度条第九周
    结巴分词python
    竞品分析
    学期总结(一)------文献挖掘
    分类结果评估
    scrapy 爬虫怎么写入日志和保存信息
    Python 安装 imread报错
    Python爬虫爬中文却显示Unicode,怎样显示中文--问题解答
    Python网络数据采集二
  • 原文地址:https://www.cnblogs.com/erci-520/p/9219745.html
Copyright © 2011-2022 走看看