当前位置:网站首页>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
边栏推荐
- StaticLayout的使用详解
- win11如何添加打印机和扫描仪?win11添加打印机和扫描仪的设置
- 【二维码图像矫正增强】基于MATLAB的二维码图像矫正增强处理仿真
- Usage differences between isempty and isblank
- How to systematically learn LabVIEW?
- [today in history] June 25: the father of notebook was born; Windows 98 release; First commercial use of generic product code
- [today in history] June 8: the father of the world wide web was born; PHP public release; IPhone 4 comes out
- CMU提出NLP新范式—重构预训练,高考英语交出134高分
- [today in history] June 18: JD was born; The online store platform Etsy was established; Facebook releases Libra white paper
- How fiddle uses agents
猜你喜欢

Design e-commerce seckill system

2-5 basic configuration -win2003 add attack surface
![[block coding] simulation of image block coding based on MATLAB](/img/d9/a9c45faf40663865893cd58e7e7431.png)
[block coding] simulation of image block coding based on MATLAB

拾光者,云南白药!

Character interception triplets of data warehouse: substrb, substr, substring

Online JSON to plaintext tool

Interpretation of bilstm-crf in NER forward_ algorithm

PSM总结

【插件-statistic】统计代码行数和相关数据

Win11不能拖拽圖片到任務欄軟件上快速打開怎麼辦
随机推荐
如何开启多语言文本建议?Win11打开多语言文本建议的方法
[today in history] June 8: the father of the world wide web was born; PHP public release; IPhone 4 comes out
Win11新建不了文本文档?Win11右键无法新建文本文档的解决方法
Interpretation of bilstm-crf in NER forward_ algorithm
ADB double click the power key command
Cloud native (30) | kubernetes' app store Helm
Intel Ruixuan A380 graphics card will be launched in China
【二維碼圖像矯正增强】基於MATLAB的二維碼圖像矯正增强處理仿真
榜单首发——前装搭载率站上10%大关,数字钥匙方案供应商TOP10
Simple elk configuration to realize production level log collection and query practice
JDBC与MySQL数据库
How to realize red, green and yellow traffic lights in ros+gazebo?
《天天数学》连载53:二月二十一日
Is it safe for qiniu to open an account? How do I open an account online?
win11如何添加打印机和扫描仪?win11添加打印机和扫描仪的设置
Usage differences between isempty and isblank
Livedata interview question bank and answers -- 7 consecutive questions for livedata interview~
Online text batch inversion by line tool
无心剑英汉双语诗004.《静心》
把腾讯搬上云:云服务器 CVM 的半部进化史