当前位置:网站首页>Gateway microservice routing failed to load microservice static resources
Gateway microservice routing failed to load microservice static resources
2022-06-28 02:57:00 【Cloud dream returns to remote】
Gateway Microservice routing causes microservice static resources to fail to load
1.Gateway
1.1 Gateway Introduce
- Gateway Gateway microservices , Provide a unified entrance for our micro service clusters , Assert based on route matching , Access the corresponding microservices
2.Gateway Before and after success
2.1 The static resource failure scenario reappears
- The static resource path introduced on the remote microservice page ,/css/index.css
<!-- Introduce the outside The style file -->
<link rel="stylesheet" type="text/css" href="../static/css/index.css" th:href="@{/css/index.css}">

- Remote microservices release static resources , Modify the configuration file
spring:
application:
name: ProductPageDemo
# Release static resources
resources:
static-locations: classpath:/static/
- Gateway Gateway profile
server:
port: 80
spring:
application:
name: GatewayDemo
cloud:
gateway:
# Configure the routing
routes:
- id: ProductPageDemo
uri: http://ProductPageDemo:9100
predicates:
# Assertion , With /page/ Match at the beginning
- Path=/page/**
filters:
# filter , The first level path will be removed and then routed
- StripPrefix=1
- For the request :http://127.0.0.1/page/page/all

2.2 Modification successful , Successfully loaded
- Because my route matching needs to remove the first level matching path , So we need to be able to Modify the static resource path when the corresponding micro service introduces static resources ,/page/css/index.css
<!-- Introduce the outside The style file -->
<link rel="stylesheet" type="text/css" href="../static/css/index.css" th:href="@{/page/css/index.css}">
- For the request :http://127.0.0.1/page/page/all

2.3 If the first level path is not removed , You can configure as follows
server:
port: 80
spring:
application:
name: GatewayDemo
cloud:
gateway:
# Configure the routing
routes:
- id: ProductPageDemo
uri: http://ProductPageDemo:9100
predicates:
# Assertion , With /page/ Match at the beginning
- Path=/page/**,/css/** # Release static resource path
边栏推荐
- How to systematically learn LabVIEW?
- 2021年软件测试工具总结——模糊测试工具
- 初始线性回归
- Flutter 使用 CustomPaint 绘制基本图形
- 分布式事务—基于消息补偿的最终一致性方案(本地消息表、消息队列)
- Shardingsphere-proxy-5.0.0 establish MySQL read / write separation connection (6)
- Heartless sword Chinese English bilingual poem 004 Sword
- 【二維碼圖像矯正增强】基於MATLAB的二維碼圖像矯正增强處理仿真
- Stm32f1 and stm32subeide programming example - metal touch sensor driver
- MFC CString to LPVOID
猜你喜欢

树莓派-环境设置和交叉编译

Usage differences between isempty and isblank
![[2D code image correction and enhancement] simulation of 2D code image correction and enhancement processing based on MATLAB](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[2D code image correction and enhancement] simulation of 2D code image correction and enhancement processing based on MATLAB

【模糊神经网络】基于matlab的模糊神经网络仿真
![[kotlin] basic introduction and understanding of its syntax in Android official documents](/img/44/ec59383ddfa2624a1616d13deda4a4.png)
[kotlin] basic introduction and understanding of its syntax in Android official documents

How does win11 close recently opened projects? Win11 method to close recently opened projects

Raspberry pie - environment settings and cross compilation
![[today in history] June 25: the father of notebook was born; Windows 98 release; First commercial use of generic product code](/img/ef/a26127284fe57ac049a4313d89cf97.png)
[today in history] June 25: the father of notebook was born; Windows 98 release; First commercial use of generic product code

微信小程序中生成二维码

【Kotlin】在Android官方文档中对其语法的基本介绍和理解
随机推荐
【模糊神经网络】基于matlab的模糊神经网络仿真
如何开启多语言文本建议?Win11打开多语言文本建议的方法
分布式事务—基于消息补偿的最终一致性方案(本地消息表、消息队列)
【Kotlin】在Android官方文档中对其语法的基本介绍和理解
STM32F1与STM32CubeIDE编程实例-金属触摸传感器驱动
拾光者,云南白药!
[today in history] June 12: the United States entered the era of digital television; Mozilla's original developer was born; 3com merges with American Robotics
MFC CString互转LPVOID
Shuttle uses custompaint to paint basic shapes
isEmpty 和 isBlank 的用法區別
Win11新建不了文本文档?Win11右键无法新建文本文档的解决方法
如何判断线程池已经执行完所有任务了?
Heartless sword Chinese English bilingual poem 004 Sword
Usage details of staticlayout
Win11 cannot create a new text document? Solution to win11 right click failure to create a new text document
LiveData 面试题库、解答---LiveData 面试 7 连问~
Simple elk configuration to realize production level log collection and query practice
[today in history] June 6: World IPv6 launch anniversary; Tetris release; Little red book established
Is it reliable to invest in the inter-bank certificate of deposit fund? Is the inter-bank certificate of deposit fund safe
Win11不能拖拽图片到任务栏软件上快速打开怎么办