当前位置:网站首页>routing----router
routing----router
2022-08-05 08:09:00 【cjx177187】
Route describes the correspondence between the request URL and the Controller that is responsible for executing the action.To put it bluntly, when users access different paths, there should be different Controllers to respond to different content.
router.get('/getdata', controller.form.get);//Static routing
Template syntax:
'use strict';
/**
* @param
*/
module.exports = app
const { router, controller
router.get('/', controller.home.index);
};
Route matching process:
- Whenever a request arrives at the server, it needs to be matched by the route first. Only after the match is successful, the corresponding processing function will be called.
- When matching, it will be matched according to the order of routing configuration; if the request type and request URL are matched successfully at the same time, EXpress will hand over the request to the corresponding function for processing.
Note:
Match in the defined order
Request type and requestURLThe corresponding function will be called only if the match is successful at the same time
When registering a route, the route name should not conflict with the static file name, otherwise static resources will be preferentially accessed.When the route names are the same, the one registered first is executed first
边栏推荐
猜你喜欢

DNS 查询原理详解

Discourse 清理存储空间的方法

JVM运行流程,运行时数据区,类加载,垃圾回收,JMM解析

Support touch screen slider carousel plugin

Game Thinking 19: Multi-dimensional calculation related to games: point product, cross product, point-line-surface distance calculation

学习机赛道加速:请“卷”产品,不要“卷”营销

高端无主灯设计灯光设计该如何布置射灯灯具?

Ethernet Principle

SVG星球大战样式Toggle切换开关按钮
![[Structure internal power practice] Structure memory alignment (1)](/img/31/4ddc16810da8238ac95a93d007e12e.png)
[Structure internal power practice] Structure memory alignment (1)
随机推荐
YOLOv3 SPP理论详解(包括CIoU及Focal loss)
【结构体内功修炼】结构体内存对齐(一)
Embedded Systems: Basic Timers
[Structural Internal Power Cultivation] Structural Realization Stages (2)
ps怎么把图片变清晰,自学ps软件photoshop2022,简单快速用ps让照片更清晰更有质感
【结构体内功修炼】枚举和联合的奥秘(三)
最 Cool 的 Kubernetes 网络方案 Cilium 入门教程
长期招聘嵌入式开发-深圳宝安
[Structural Internal Power Cultivation] The Mystery of Enumeration and Union (3)
Green Apple Forum reopens
Qt编写自定义控件:文字聚光灯效果之一
常用的遍历map的方法
U++ 创建UI
七夕看什么电影好?爬取电影评分并存入csv文件
奇怪的Access错误
Codeforce 8.1-8.7做题记录
php向mysql写入数据失败
高效使用数码相机的诀窍
Adb authorization process analysis
8.4模拟赛总结