当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
pnpm 是凭什么对 npm 和 yarn 降维打击的
版本号命名规则
Mysql 死锁和死锁的解决方案
props 后面的数据流是什么?
Jmeter永久设置中文界面
Beautifully painted MM set
基于多块信息提取和马氏距离的k近邻故障监测
学习笔记14--机器学习在局部路径规划中的应用
iptables实现网络限制下ntp自定义端口同步时间
Redis cache and existing problems--cache penetration, cache avalanche, cache breakdown and solutions
利用Jenkins的持续集成
生命的颜色占卜
监听浏览器刷新操作
MVCC of Google's Fragmented Notes (Draft)
Liunx教程超详细(完整)
高效使用数码相机的诀窍
Illegal key size 报错问题
php向mysql写入数据失败
Qt writes custom controls: one of the text spotlight effects
作为一个男人必须明白的22个道理