首页>代码>SpringCloud微服务的项目架构搭建及Springboot应用实例>/demo/src/main/java/com/example/controller/UserController.java
package com.example.controller;

import com.example.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author:qianjc
 * 2019/2/21
 */


@RestController
@RequestMapping("/testBoot")
public class UserController {

    @Autowired
    private UserService userService;

    //@PathVariable 映射 URL 绑定的占位符
    // 带占位符的 URL 是 Spring3.0 新增的功能,该功能在SpringMVC 向 REST 目标挺进发展过程中具有里程碑的意义
    // 通过 @PathVariable 可以将 URL 中占位符参数绑定到控制器处理方法的入参中:URL 中的 {xxx} 占位符可以通过@PathVariable(“xxx“) 绑定到操作方法的入参中。
    @RequestMapping("getUser/{id}")
    public String GetUser(@PathVariable int id){
        return userService.Sel(id).toString();
    }

}


最近下载更多
iceboard  LV2 2023年2月26日
wl010101  LV9 2022年4月22日
林志勇  LV10 2022年3月11日
sunlzh888888  LV28 2021年6月22日
一米八二约德尔  LV1 2021年5月30日
mojunxin  LV4 2021年3月31日
xhmpmail  LV17 2021年2月23日
123456nty  LV37 2020年10月14日
李海洋  LV12 2020年6月21日
liuwenlong  LV20 2020年5月26日
最近浏览更多
哪里的完整版  LV7 2023年12月15日
落后就要挨打  LV26 2023年10月19日
zhy1989wz  LV6 2023年9月11日
高腾达  LV3 2023年6月11日
lt33333  LV7 2023年6月5日
ypf8312  LV22 2023年5月9日
流连瓦盖法  LV7 2023年3月21日
最代码安逸  LV15 2023年3月1日
iceboard  LV2 2023年2月26日
秦sir3067683450  LV10 2022年12月31日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友