zoukankan      html  css  js  c++  java
  • spring boot 入门学习

    开始学习spring boot 相关知识,尝试建立web项目。

    首先建立一个空项目,然后进行配置相关文件

    Application代码如下:

    1 @SpringBootApplication
    2 public class Application {
    3 
    4     public static void main(String[] args) throws Exception {
    5         SpringApplication.run(Application.class, args);
    6     }
    7 
    8 }

    application我理解位程序入口,具体详细原理以后再学习

    Controller,控制器代码如下:

     1 @Controller  /*返回视图页名称*/
     2 //@RestController  返回json数据类型
     3 public class MainController {
     4 
     5     @RequestMapping("index")//连接访问名称
     6     public String index() {
     7         return "hello";//返回视图名称
     8     }
     9 
    10     @RequestMapping("hello")
    11     public String hello() {
    12         return "hello";
    13     }
    14 }

    application.yaml  配置文件,设置端口以及spring相关属性。

     1 debug: false
     2 
     3 server:
     4     port: 8080
     5 
     6 
     7 spring:
     8     http:
     9         encoding:
    10         charset: utf-8
    11         enabled: true
    12         force: true
    13     thymeleaf:
    14         mode: HTML5
    15         encoding: UTF-8
    16         content-type: text/html
    17         cache: false
    18         prefix: classpath:/templates/
    19         suffix: .html
    20     resources:
    21         static-locations: classpath:/static/

    pom的配置文件就不详细说明了  ,根据需要进行配置。

    这里说明SpringBoot的配置代码

     1 <parent>
     2     <groupId>org.springframework.boot</groupId>
     3     <artifactId>spring-boot-starter-parent</artifactId>
     4     <version>1.5.9.RELEASE</version>
     5 </parent>
     6 <dependencies>
     7     <dependency>
     8         <groupId>org.springframework.boot</groupId>
     9         <artifactId>spring-boot-starter-web</artifactId>
    10     </dependency>
    11 </dependencies>

    over

  • 相关阅读:
    事件对象
    type of 操作符和instanceof操作符的区别以及使用方法
    JS:XML
    JS:事件处理程序
    JS:event对象下的target属性和取消冒泡事件
    JS:callee属性
    JS:call()和apply的区别
    JS:事件对象1
    DOM元素的大小和位置
    CSS:在IE浏览器下,元素下沉一行的解决办法
  • 原文地址:https://www.cnblogs.com/yishilin/p/8302300.html
Copyright © 2011-2022 走看看