1.maven引入包

  1. <dependency>
  2. <groupId>org.springframework.cloud</groupId>
  3. <artifactId>spring-cloud-starter-netflix-zuul</artifactId>
  4. </dependency>
  5.  
  6. <dependency>
  7. <groupId>org.springframework.cloud</groupId>
  8. <artifactId>spring-cloud-starter-eureka</artifactId>
  9. </dependency>

2.配置文件

  1. zuul:
  2. host:
  3. socket-timeout-millis: 180000
  4. connect-timeout-millis: 180000
  5. max-total-connections: 1000
  6. #忽略所有服务
  7. ignoredServices: '*'
  8. #添加主机头
  9. addHostHeader: true
  10. #是否默认支持重试
  11. retryable: true
  12. #路由前缀
  13. prefix: /webmicroservice
  14. #自定义路由
  15. routes:
  16. leaguer:
  17. path: /leaguer/**
  18. serviceId: leaguer
  19. customSensitiveHeaders: true

3.自定义过滤器,都继承zuulFilter,实现其方法

3.1

  1. public class AuthFilter extends ZuulFilter {
  2. @Override
  3. public String filterType() {
  4. //类型为pre,前置
  5. return FilterConstants.PRE_TYPE;
  6. }
  7.  
  8. @Override
  9. public int filterOrder() {
  10. //顺序为数字为6
  11. return FilterConstants.PRE_DECORATION_FILTER_ORDER + 1;
  12. }
  13.  
  14. @Override
  15. public boolean shouldFilter() {
  16. //无条件执行
  17. return true;
  18. }
  19.  
  20. @Override
  21. public Object run() {
  22. RequestContext context = RequestContext.getCurrentContext();
  23. //TODO 实现自己需要执行的逻辑如,鉴定权限相关.....
  24. log.info("authFilter----->pre_type----->order=6");
  25. return null;
  26. }
  27. }
  1. public class LoginPostFilter extends ZuulFilter {
  2. @Override
  3. public String filterType() {
  4. //类型为post,后置
  5. return FilterConstants.POST_TYPE;
  6. }
  7.  
  8. @Override
  9. public int filterOrder() {
  10. //顺序为数字为999
  11. return FilterConstants.SEND_RESPONSE_FILTER_ORDER - 1;
  12. }
  13.  
  14. @Override
  15. public boolean shouldFilter() {
  16. //无条件执行
  17. return true;
  18. }
  19.  
  20. @Override
  21. public Object run() {
  22. //TODO 实现自己需要执行的逻辑如,登录后做些什么
  23. log.info("loginFilter----->post_type----->order=999");
  24. return null;
  25. }
  26. }

3.2实例化,注入spring容器

  1. @Bean
  2. public AuthFilter getAuthFilter(){
  3. return new AuthFilter();
  4. }
  5.  
  6. @Bean
  7. public LoginPostFilter getLoginPostFilter(){
  8. return new LoginPostFilter();
  9. }

4.启动服务且发送请求

  1. ::14.266 DEBUG --- [nio--exec-] o.s.b.w.f.OrderedRequestContextFilter : Bound request context to thread: org.apache.catalina.connector.RequestFacade@fa6901d
  2. ::14.266 DEBUG --- [nio--exec-] o.s.web.servlet.DispatcherServlet : DispatcherServlet with name 'dispatcherServlet' processing POST request for [/webmicroservice/leaguer/leaUser/createImge]
  3. ::14.266 DEBUG --- [nio--exec-] o.s.c.n.zuul.filters.SimpleRouteLocator : route matched=ZuulRoute{id='leaguer', path='/leaguer/**', serviceId='leaguer', url='null', stripPrefix=true, retryable=null, sensitiveHeaders=[], customSensitiveHeaders=true, }
  4. ::14.266 DEBUG --- [nio--exec-] o.s.c.n.zuul.web.ZuulHandlerMapping : Matching patterns for request [/webmicroservice/leaguer/leaUser/createImge] are [/webmicroservice/leaguer/**]
  5. 11:39:14.266 DEBUG 12920 --- [nio-8116-exec-2] o.s.c.n.zuul.web.ZuulHandlerMapping : URI Template variables for request [/webmicroservice/leaguer/leaUser/createImge] are {}
  6. 11:39:14.266 DEBUG 12920 --- [nio-8116-exec-2] o.s.c.n.zuul.web.ZuulHandlerMapping : Mapping [/webmicroservice/leaguer/leaUser/createImge] to HandlerExecutionChain with handler [org.springframework.cloud.netflix.zuul.web.ZuulController@1f78d415] and 1 interceptor
  7. 11:39:14.267 DEBUG 12920 --- [nio-8116-exec-2] c.n.zuul.http.HttpServletRequestWrapper : Path = null
  8. 11:39:14.267 DEBUG 12920 --- [nio-8116-exec-2] c.n.zuul.http.HttpServletRequestWrapper : Transfer-Encoding = null
  9. 11:39:14.267 DEBUG 12920 --- [nio-8116-exec-2] c.n.zuul.http.HttpServletRequestWrapper : Content-Encoding = null
  10. 11:39:14.267 DEBUG 12920 --- [nio-8116-exec-2] c.n.zuul.http.HttpServletRequestWrapper : Content-Length header = 12
  11. 11:39:14.267 DEBUG 12920 --- [nio-8116-exec-2] c.n.zuul.http.HttpServletRequestWrapper : Length of contentData byte array = 12
  12. 11:39:14.267 DEBUG 12920 --- [nio-8116-exec-2] o.s.c.n.zuul.filters.SimpleRouteLocator : Finding route for path: /webmicroservice/leaguer/leaUser/createImge
  13. 11:39:14.267 DEBUG 12920 --- [nio-8116-exec-2] o.s.c.n.zuul.filters.SimpleRouteLocator : servletPath=/
  14. 11:39:14.267 DEBUG 12920 --- [nio-8116-exec-2] o.s.c.n.zuul.filters.SimpleRouteLocator : zuulServletPath=/zuul
  15. 11:39:14.267 DEBUG 12920 --- [nio-8116-exec-2] o.s.c.n.zuul.filters.SimpleRouteLocator : RequestUtils.isDispatcherServletRequest()=true
  16. 11:39:14.267 DEBUG 12920 --- [nio-8116-exec-2] o.s.c.n.zuul.filters.SimpleRouteLocator : RequestUtils.isZuulServletRequest()=false
  17. 11:39:14.267 DEBUG 12920 --- [nio-8116-exec-2] o.s.c.n.zuul.filters.SimpleRouteLocator : adjustedPath=/webmicroservice/leaguer/leaUser/createImge
  18. 11:39:14.267 DEBUG 12920 --- [nio-8116-exec-2] o.s.c.n.zuul.filters.SimpleRouteLocator : Matching pattern:/webmicroservice/leaguer/**
  19. 11:39:14.267 DEBUG 12920 --- [nio-8116-exec-2] o.s.c.n.zuul.filters.SimpleRouteLocator : route matched=ZuulRoute{id='leaguer', path='/leaguer/**', serviceId='leaguer', url='null', stripPrefix=true, retryable=null, sensitiveHeaders=[], customSensitiveHeaders=true, }
  20. 11:39:14.268 INFO 12920 --- [nio-8116-exec-2] c.e.springbootzuul.filters.AuthFilter : authFilter----->pre_type----->order=6
  21. 11:39:14.268 DEBUG 12920 --- [nio-8116-exec-2] o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'ribbonLoadBalancingHttpClient'
  22. 11:39:14.268 DEBUG 12920 --- [nio-8116-exec-2] o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'ribbonLoadBalancer'
  23. 11:39:14.268 DEBUG 12920 --- [nio-8116-exec-2] o.s.b.f.s.DefaultListableBeanFactory : Returning cached instance of singleton bean 'ribbonClientConfig'
  24. 11:39:14.269 DEBUG 12920 --- [nio-8116-exec-2] c.n.loadbalancer.ZoneAwareLoadBalancer : Zone aware logic disabled or there is only one zone
  25. 11:39:14.269 DEBUG 12920 --- [nio-8116-exec-2] c.n.loadbalancer.LoadBalancerContext : leaguer using LB returned Server: 10.0.126.14:8085 for request /leaUser/createImge
  26. 11:39:14.270 DEBUG 12920 --- [nio-8116-exec-2] o.a.h.client.protocol.RequestAuthCache : Auth cache not set in the context
  27. 11:39:14.270 DEBUG 12920 --- [nio-8116-exec-2] h.i.c.PoolingHttpClientConnectionManager : Connection request: [route: {}->http://10.0.126.14:8085][total kept alive: 1; route allocated: 1 of 50; total allocated: 1 of 200]
  28. 11:39:14.271 DEBUG 12920 --- [nio-8116-exec-2] org.apache.http.wire : http-outgoing-0 << "[read] I/O error: Read timed out"
  29. 11:39:14.271 DEBUG 12920 --- [nio-8116-exec-2] h.i.c.PoolingHttpClientConnectionManager : Connection leased: [id: 0][route: {}->http://10.0.126.14:8085][total kept alive: 0; route allocated: 1 of 50; total allocated: 1 of 200]
  30. 11:39:14.271 DEBUG 12920 --- [nio-8116-exec-2] h.i.c.DefaultManagedHttpClientConnection : http-outgoing-0: set socket timeout to 0
  31. 11:39:14.271 DEBUG 12920 --- [nio-8116-exec-2] h.i.c.DefaultManagedHttpClientConnection : http-outgoing-0: set socket timeout to 1000
  32. 11:39:14.271 DEBUG 12920 --- [nio-8116-exec-2] o.a.http.impl.execchain.MainClientExec : Executing request POST /leaUser/createImge HTTP/1.1
  33. 11:39:14.271 DEBUG 12920 --- [nio-8116-exec-2] o.a.http.impl.execchain.MainClientExec : Target auth state: UNCHALLENGED
  34. 11:39:14.271 DEBUG 12920 --- [nio-8116-exec-2] o.a.http.impl.execchain.MainClientExec : Proxy auth state: UNCHALLENGED
  35. 11:39:14.271 DEBUG 12920 --- [nio-8116-exec-2] org.apache.http.headers : http-outgoing-0 >> POST /leaUser/createImge HTTP/1.1
  36. 11:39:14.271 DEBUG 12920 --- [nio-8116-exec-2] org.apache.http.headers : http-outgoing-0 >> accept-language: zh-CN,zh;q=0.9
  37. 11:39:14.271 DEBUG 12920 --- [nio-8116-exec-2] org.apache.http.headers : http-outgoing-0 >> referer: http://localhost:9200/vip/login
  38. 11:39:14.271 DEBUG 12920 --- [nio-8116-exec-2] org.apache.http.headers : http-outgoing-0 >> content-type: application/x-www-form-urlencoded
  39. 11:39:14.272 DEBUG 12920 --- [nio-8116-exec-2] org.apache.http.headers : http-outgoing-0 >> user-agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36
  40. 11:39:14.272 DEBUG 12920 --- [nio-8116-exec-2] org.apache.http.headers : http-outgoing-0 >> origin: http://localhost:9200
  41. 11:39:14.272 DEBUG 12920 --- [nio-8116-exec-2] org.apache.http.headers : http-outgoing-0 >> accept: application/json, text/plain, */*
  42. ::14.272 DEBUG --- [nio--exec-] org.apache.http.headers : http-outgoing- >> x-forwarded-host: localhost:
  43. ::14.272 DEBUG --- [nio--exec-] org.apache.http.headers : http-outgoing- >> x-forwarded-proto: http
  44. ::14.272 DEBUG --- [nio--exec-] org.apache.http.headers : http-outgoing- >> x-forwarded-prefix: /webmicroservice/leaguer
  45. ::14.272 DEBUG --- [nio--exec-] org.apache.http.headers : http-outgoing- >> host: localhost:
  46. ::14.272 DEBUG --- [nio--exec-] org.apache.http.headers : http-outgoing- >> x-forwarded-port:
  47. ::14.272 DEBUG --- [nio--exec-] org.apache.http.headers : http-outgoing- >> x-forwarded-for: 10.0.126.14
  48. ::14.272 DEBUG --- [nio--exec-] org.apache.http.headers : http-outgoing- >> Accept-Encoding: gzip
  49. ::14.272 DEBUG --- [nio--exec-] org.apache.http.headers : http-outgoing- >> Content-Length:
  50. ::14.272 DEBUG --- [nio--exec-] org.apache.http.headers : http-outgoing- >> Connection: Keep-Alive
  51. ::14.272 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- >> "POST /leaUser/createImge HTTP/1.1[\r][\n]"
  52. ::14.272 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- >> "accept-language: zh-CN,zh;q=0.9[\r][\n]"
  53. ::14.272 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- >> "referer: http://localhost:9200/vip/login[\r][\n]"
  54. ::14.272 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- >> "content-type: application/x-www-form-urlencoded[\r][\n]"
  55. ::14.272 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- >> "user-agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36[\r][\n]"
  56. ::14.272 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- >> "origin: http://localhost:9200[\r][\n]"
  57. ::14.272 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- >> "accept: application/json, text/plain, */*[\r][\n]"
  58. ::14.272 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- >> "x-forwarded-host: localhost:9200[\r][\n]"
  59. ::14.272 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- >> "x-forwarded-proto: http[\r][\n]"
  60. ::14.272 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- >> "x-forwarded-prefix: /webmicroservice/leaguer[\r][\n]"
  61. ::14.272 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- >> "host: localhost:9200[\r][\n]"
  62. ::14.272 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- >> "x-forwarded-port: 9200[\r][\n]"
  63. ::14.272 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- >> "x-forwarded-for: 10.0.126.14[\r][\n]"
  64. ::14.272 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- >> "Accept-Encoding: gzip[\r][\n]"
  65. ::14.272 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- >> "Content-Length: 12[\r][\n]"
  66. ::14.272 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- >> "Connection: Keep-Alive[\r][\n]"
  67. ::14.272 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- >> "[\r][\n]"
  68. ::14.272 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- >> "param=e30%3D"
  69. ::14.330 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- << "HTTP/1.1 200 OK[\r][\n]"
  70. ::14.330 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- << "Connection: keep-alive[\r][\n]"
  71. ::14.330 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- << "Transfer-Encoding: chunked[\r][\n]"
  72. ::14.330 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- << "Content-Type: application/json;charset=UTF-8[\r][\n]"
  73. ::14.330 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- << "X-Application-Context: leaguer[\r][\n]"
  74. ::14.330 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- << "Date: Wed, 03 Jul 2019 03:39:14 GMT[\r][\n]"
  75. ::14.330 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- << "[\r][\n]"
  76. ::14.330 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- << "045d[\r][\n]"
  77. ::14.330 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- << "{"result":"eyJjb2RlIjowLCJkZXRhaWwiOiLojrflj5blm77lvaLpqozor4HnoIHmiJDlip8iLCJlbnRpdHkiOnsiaW1nU3RyIjoiZGF0YTppbWFnZS9wbmc7YmFzZTY0LGlWQk9SdzBLR2dvQUFBQU5TVWhFVWdBQUFIZ0FBQUFvQ0FJQUFBQzZpS2x5QUFBQnNVbEVRVlI0MnUzYnUwMEFNUXdBMEt0b3FHaFlnRG5ZZ3c3Uk1BSkx3QllVRkZRMENGcm9tQUxXb0FCT1FvcWloSFA4aStNTHRsem1ybmhuMlVta1c3NGpUR0lKZ29BT2FQTTRmYjZZQi9ybDVpNGw1c2w4UGZLUjY2KzNsQXhyZ1B2cDdLaVpqaW9hRDhkUUZrTEQzQmpvc2R3YzZGSEtXOXg0NVlIV0MwT1FvYXdMWFhCVG9ZZFlMMVJFbm5MWE9ibG1VOUExZEUzSmF4cTlZNFZMMXZBeVI5QkF6VXFVMWZ0R3pRZHZTMGpRSDUrWEtTVnJDTkFKOVBYOHlrTTIrUUJ1UldpcTh1YUJwWVlXZGd5RGlzNzU0RzFKOFliYmt3Y1gwQ3A5MlFhNnlHSk9idFZ5RFoxVHFpaFBEbDF6Ly9rR0dMclE1Q2xEZHgxektPZmNKT3VSMEd3T0Q5RHdHRVJDczVVYnQzZGFXMmJqU2NnNHJRUzBEblJ6SldZZVNwUXRvSE5sWFdqU3FWclNQZVRLMkI2OTkzSkdRdDhmdks4WjBMMGE5Szl2VGx6M0NxSHlQTkNNWFVmaEM4L0RnQ1lyYjlVdnhscjU5bTVLWmNCWGN1a1IwQVRma2RCYTBROGFEcEt2VFV3RjdkRFhBdHBNMmJOdlIramlLTmdQZWhlK3ZhQU5sUGZsYXdmOXozMk5obUg0ZW9lZXh0Y3Y5R1MrcHRDUHg0ZjJHUlZ0Rk42K2J2eGFFUlVkMEJHTStBRllKSk56YmJRODhRQUFBQUJKUlU1RXJrSmdnZz09IiwidXVpZCI6ImU2Yjc4OWJlLTU2ZjAtNDAxMS05N2NmLTBiZThiMzc2NjQ0NCJ9LCJnZW5lcmFsQnVzaW5lc3NFeGNlcHRpb24iOm51bGx9"}[\r][\n]"
  78. ::14.330 DEBUG --- [nio--exec-] org.apache.http.headers : http-outgoing- << HTTP/1.1 OK
  79. ::14.330 DEBUG --- [nio--exec-] org.apache.http.headers : http-outgoing- << Connection: keep-alive
  80. ::14.330 DEBUG --- [nio--exec-] org.apache.http.headers : http-outgoing- << Transfer-Encoding: chunked
  81. ::14.330 DEBUG --- [nio--exec-] org.apache.http.headers : http-outgoing- << Content-Type: application/json;charset=UTF-
  82. ::14.330 DEBUG --- [nio--exec-] org.apache.http.headers : http-outgoing- << X-Application-Context: leaguer
  83. ::14.333 DEBUG --- [nio--exec-] org.apache.http.headers : http-outgoing- << Date: Wed, Jul :: GMT
  84. ::14.333 DEBUG --- [nio--exec-] o.a.http.impl.execchain.MainClientExec : Connection can be kept alive indefinitely
  85. ::14.334 INFO --- [nio--exec-] c.e.s.filters.LoginPostFilter : loginFilter----->post_type----->order=
  86. ::14.334 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- << "0[\r][\n]"
  87. ::14.334 DEBUG --- [nio--exec-] org.apache.http.wire : http-outgoing- << "[\r][\n]"
  88. ::14.334 DEBUG --- [nio--exec-] h.i.c.PoolingHttpClientConnectionManager : Connection [id: ][route: {}->http://10.0.126.14:8085] can be kept alive indefinitely
  89. ::14.334 DEBUG --- [nio--exec-] h.i.c.DefaultManagedHttpClientConnection : http-outgoing-: set socket timeout to
  90. ::14.334 DEBUG --- [nio--exec-] h.i.c.PoolingHttpClientConnectionManager : Connection released: [id: ][route: {}->http://10.0.126.14:8085][total kept alive: 1; route allocated: 1 of 50; total allocated: 1 of 200]
  91. ::14.335 DEBUG --- [nio--exec-] o.s.web.servlet.DispatcherServlet : Null ModelAndView returned to DispatcherServlet with name 'dispatcherServlet': assuming HandlerAdapter completed request handling
  92. ::14.335 DEBUG --- [nio--exec-] o.s.web.servlet.DispatcherServlet : Successfully completed request

springcloud -zuul(1-zuul的简单使用)的更多相关文章

  1. SpringCloud学习之zuul

    一.为什么要有网关 我们先看一个图,如果按照consumer and server(最初的调用方式),如下所示 这样我们要面临如下问题: 1. 用户面临着一对N的问题既用户必须知道每个服务.随着服务的 ...

  2. SpringCloud之网关 Zuul(四)

    一 Zuul简介 zuul 是netflix开源的一个API Gateway 服务器, 本质上是一个web servlet应用. Zuul 在云平台上提供动态路由,监控,弹性,安全等边缘服务的框架.Z ...

  3. 基于SpringCloud搭建项目-Zuul篇(六)

    本文主要介绍zuul的基本原理和在sprngcloud服务下如何使用 一.简单介绍 Zuul 是 Netflix OSS 中的一员,是一个基于 JVM 路由和服务端的负载均衡器.提供路由.监控.弹性. ...

  4. springcloud 实战 网关zuul使用中遇到的相关问题

    springcloud 实战  网关zuul使用中遇到的相关问题 1.网关zuul使用时,跨域问题在网关中配置pre过滤器: response.setHeader("Access-Contr ...

  5. SpringCloud解析之Zuul(二)

    本文基于Spring Cloud Edgware.SR6,Zuul版本1.3.1,解析Zuul的请求拦截机制,让大家对Zuul的原理有个大概的认识和了解.如有不对的地方,欢迎指正. 在上一期的Spri ...

  6. SpringCloud:路由ZUUL的配置详解

    以下是两种配置文件的配置方式,可以根据需要选取对自己项目有利的配置. 自定义访问路径(path) 配置application.yml文件 #provider-user:是你的微服务模块的名称,及spr ...

  7. spring cloud: zuul(二): zuul的serviceId/service-id配置(微网关)

    spring cloud: zuul(二): zuul的serviceId/service-id配置(微网关) zuul: routes: #路由配置表示 myroute1: #路由名一 path: ...

  8. SpringCloud配置刷新机制的简单分析[nacos为例子]

    SpringCloud Nacos 本文主要分为SpringCloud Nacos的设计思路 简单分析一下触发刷新事件后发生的过程以及一些踩坑经验 org.springframework.cloud. ...

  9. springcloud微服务总结 zuul

    一 springcloud网关组件理解: 为什么需要网关呢? 我们知道我们要进入一个服务本身,很明显我们没有特别好的办法,直接输入IP地址+端口号,我们知道这样的做法很糟糕的,这样的做法大有问题,首先 ...

  10. SpringCloud学习之Zuul统一异常处理及回退

    一.Filter中统一异常处理 其实在SpringCloud的Edgware SR2版本中对于ZuulFilter中的错误有统一的处理,但是在实际开发当中对于错误的响应方式,我想每个团队都有自己的处理 ...

随机推荐

  1. 【记录】uni-app Chrome跨域解决方案插件 has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is...

    博主最近在用Hbuilder X开发前端网页时, 出现了has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header ...

  2. Dubbox服务的提供方配置

    在src/main/resources下创建applicationContext-service.xml ,内容如下: <?xml version="1.0" encodin ...

  3. pygame征途:(一)图片移动反弹

    题目大意: 就是弄一张图片在背景画布上移动,然后碰到边界就图片翻转并且反向移动 基本思路: 需要pygame常用的一些常用的函数,然后基本就是在背景画布上blit一张图片,然后移动就是先全刷成背景画布 ...

  4. Qt 【Qlistview + delegate 为item重写个关闭按钮】

    效果图是这样的. 实现的过程是listview + delegate 本身我想是用listwidget + delegate[网上查询到不可实现] 之前也试过在item中添加布局跟控件,但是在点击的时 ...

  5. thymeleaf onclick方法向js方法传递参数

    如下图 这个错误并不影响 请放心使用

  6. STL————bitset

    C++的 bitset 在 bitset 头文件中,它是一种类似数组的结构,它的每一个元素只能是0或1,每个元素仅用1bit空间. bitset<> bitset1; //无参构造,长度为 ...

  7. Ubuntu 14.04 搭建 LNMP

    LNMP(Linux-Nginx-MySQL-PHP)这四种软件的组合,可以成为一个免费.高效.扩展性强的网站服务系统. 一.操作步骤 1.安装Nginx sudo apt-get update su ...

  8. LeetCode刷题笔记-DP算法-取数问题

    题目描述 (除数博弈论)爱丽丝和鲍勃一起玩游戏,他们轮流行动.爱丽丝先手开局. 最初,黑板上有一个数字 N .在每个玩家的回合,玩家需要执行以下操作: 选出任一 x,满足 0 < x < ...

  9. 剑指offer——42最小的K个数

    题目描述 输入n个整数,找出其中最小的K个数.例如输入4,5,1,6,2,7,3,8这8个数字,则最小的4个数字是1,2,3,4,.   题解: 原以为书中会有好方法,想不到还是排序和STL这两种方法 ...

  10. Bootstrap入门及其常用内置实现

    BootStrap是一个专门做页面的 1.BS是基于HTML CSS JS 的一个前端框架(半成品) 2.预定义了一套CSS样式与JQurey实现 3.BS和Validation类似,都是JQ的插件, ...