【SpringBoot】第4章 Web开发 4.1 Web开发简介

avatar
作者
猴君
阅读量:0

60,23:23

<dependency>

<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starer-web</artifactId>

</dependency>

@RestController

public class HelloController{

    @RequestMapping("/hello")

    public String hello(){

    return "hello,world";

}

}    9

@Controller

@RequestMapping("user")

public class UserController{

    @RequestMapping("/index")

    public String index(){

    map.addAttribute("name","thymeleaf-index");

    return "thymeleaf/index";

}16

@Controller

public class HelloController{

    @RequestMapping("/hello")

    @ResponseBody

   public String hello(){

  return "hello,world";

}

}22

@RestController

@RequestMapping("/user")

public class UserController{

    @RequestMapping("/getUser")

    public User getUser(){

     User u = new User();

     u.setName("tianlong");

    u.setAge(32);

    u.setPassword("lysoft");

    return u; 

}

}32

@Controller

@RequestMapping("/user")

public class UserController{

    @RequestMapping("/getUser")

    @ResponseBody

    public User getUser(){

    User u = new User();

    u.setName("tianlong");

    u.setAge(20);

    u.setPassword("123456");

    return u;

}

}43

广告一刻

为您即时展示最新活动产品广告消息,让您随时掌握产品活动新动态!