SpringBoot处理url中的参数的注解

SpringBoot处理url中的参数的注解

@PathVaribale 获取url中的数据

@RequestParam 获取请求参数的值

@GetMapping 组合注解,是 @RequestMapping(method = RequestMethod.GET) 的缩写

@RestController
public class HelloController {
    @RequestMapping(value="/hello/{id}/{name}",method= RequestMethod.GET)
    public String sayHello(@PathVariable("id") Integer id,@PathVariable("name") String name){
        return "id:"+id+" name:"+name;
    }
}

在浏览器中 输入地址: localhost:8080/hello/100/helloworld 然后会在html页面上打印出:

加粗样式
最近在实践

Spring Boot 2+Spring Cloud(Finchley.M9)

在用到Feign的时候发现

@EnableFeignClients

注解开不了,独立使用Feign是可以的,但就是开启不了Spring对Feign的支持.经过一番摸索终于把问题解决了,在这里分享一下解决方案和思路.

Spring Cloud对Feign的支持

org.springframework.cloud:spring-cloud-netflix-core

移到

org.springframework.cloud:spring-cloud-openfeign-core

而Finchley.M9版本下的

spring-cloud-starter-openfeign:2.0.0.M2

的pom依赖文件中导入的是

spring-cloud-netflix-core

而非

spring-cloud-openfeign-core

需要我们在pom文件中添加对应依赖管理使

spring-cloud-starter-openfeign

版本更新到

2.0.0.RC1

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-openfeign</artifactId>
            <version>2.0.0.RC1</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值