【SpringBoot】第4章 Web开发 4.1 Web开发简介
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
原文地址:https://blog.csdn.net/wenhuakulv2008/article/details/140648752
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!