如何使用nodejs 消息中间件作为java和前端的中间件

通常HTTP URL的格式是这样的:
http表示协议。
host表示主机。
port为端口,可选字段,不提供时默认为80。
path指定请求资源的URI(Uniform Resource Identifier,统一资源定位符),如果URL中没有给出path,一般会默认成&/&(通常由浏览器或其它HTTP客户端完成补充上)。
所谓路由,就是如何处理HTTP请求中的路径部分。比如&&这个URL,路由将决定怎么处理/users/profile这个路径。
来回顾我们在中提供的express版本的HelloWorld代码:
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('Hello World!');
app.listen(8000, function () {
console.log('Hello World is listening at port 8000');
上面代码里的app.get()调用,实际上就为我们的网站添加了一条路由,指定&/&这个路径由get的第二个参数所代表的函数来处理。
express对象可以针对常见的HTTP方法指定路由,使用下面的方法:
app.METHOD(path, callback [, callback ...])
使用字符串的路由路径示例:
// 匹配根路径的请求
app.get('/', function (req, res) {
res.send('root');
// 匹配 /about 路径的请求
app.get('/about', function (req, res) {
res.send('about');
// 匹配 /random.text 路径的请求
app.get('/random.text', function (req, res) {
res.send('random.text');
使用字符串模式的路由路径示例:
// 匹配 acd 和 abcd
app.get('/ab?cd', function(req, res) {
res.send('ab?cd');
// 匹配 abcd、abbcd、abbbcd等
app.get('/ab+cd', function(req, res) {
res.send('ab+cd');
// 匹配 abcd、abxcd、abRABDOMcd、ab123cd等
app.get('/ab*cd', function(req, res) {
res.send('ab*cd');
// 匹配 /abe 和 /abcde
app.get('/ab(cd)?e', function(req, res) {
res.send('ab(cd)?e');
字符 ?、+、* 和 () 是正则表达式的子集,- 和 . 在基于字符串的路径中按照字面值解释。使用正则表达式的路由路径示例:
// 匹配任何路径中含有 a 的路径:
app.get(/a/, function(req, res) {
res.send('/a/');
// 匹配 butterfly、dragonfly,不匹配 butterflyman、dragonfly man等
app.get(/.*fly$/, function(req, res) {
res.send('/.*fly$/');
可以为请求处理提供多个回调函数,其行为类似 中间件。唯一的区别是这些回调函数有可能调用 next('route') 方法而略过其他路由回调函数。可以利用该机制为路由定义前提条件,如果在现有路径上继续执行没有意义,则可将控制权交给剩下的路径。
路由句柄有多种形式,可以是一个函数、一个函数数组,或者是两者混合,如下所示.
使用一个回调函数处理路由:
app.get('/example/a', function (req, res) {
res.send('Hello from A!');
使用多个回调函数处理路由(记得指定 next 对象):
app.get('/example/b', function (req, res, next) {
console.log('response will be sent by the next function ...');
}, function (req, res) {
res.send('Hello from B!');
使用回调函数数组处理路由:
var cb0 = function (req, res, next) {
console.log('CB0');
var cb1 = function (req, res, next) {
console.log('CB1');
var cb2 = function (req, res) {
res.send('Hello from C!');
app.get('/example/c', [cb0, cb1, cb2]);
混合使用函数和函数数组处理路由:
var cb0 = function (req, res, next) {
console.log('CB0');
var cb1 = function (req, res, next) {
console.log('CB1');
app.get('/example/d', [cb0, cb1], function (req, res, next) {
console.log('response will be sent by the next function ...');
}, function (req, res) {
res.send('Hello from D!');
METHOD可以是GET、POST等HTTP方法的小写,例如app.get,app.post。path部分呢,既可以是字符串字面量,也可以是正则表达式。最简单的例子,把前面代码里的app.get()调用的一个参数&/&修改为&*&,含义就不一样。改动之前,只有访问&&或&&这种形式的访问才会返回&Hello World!&,而改之后呢,像&&这种访问也会返回&Hello World!&。
使用express构建Web服务器时,很重要的一部分工作就是决定怎么响应针对某个路径的请求,也即路由处理。
最直接的路由配置方法,就是调用app.get()、app.post()一条一条的配置,不过对于需要处理大量路由的网站来讲,这会搞出人命来的。所以呢,我们实际开发中需要结合路由参数(query string、正则表达式、自定义的参数、post参数)来减小工作量提高可维护性。更详细的信息,参考。
Express里有个中间件()的概念。所谓中间件,就是在收到请求后和发送响应之前这个阶段执行的一些函数。
要在一条路由的处理链上插入中间件,可以使用express对象的use方法。该方法原型如下:
app.use([path,] function [, function...])
当app.use没有提供path参数时,路径默认为&/&。当你为某个路径安装了中间件,则当以该路径为基础的路径被访问时,都会应用该中间件。比如你为&/abcd&设置了中间件,那么&/abcd/xxx&被访问时也会应用该中间件。
中间件函数的原型如下:
function (req, res, next)
第一个参数是对象req。第二个参数是对象res。第三个则是用来驱动中间件调用链的函数next,如果你想让后面的中间件继续处理请求,就需要调用next方法。
给某个路径应用中间件函数的典型调用是这样的:
app.use('/abcd', function (req, res, next) {
console.log(req.baseUrl);
app.static中间件
Express提供了一个static中间件,可以用来处理网站里的静态文件的GET请求,可以通过访问。
express.static的用法如下:
express.static(root, [options])
第一个参数root,是要处理的静态资源的根目录,可以是绝对路径,也可以是相对路径。第二个可选参数用来指定一些选项,比如maxAge、lastModified等,更多选项的介绍看这里:。
一个典型的express.static应用如下:
var options = {
dotfiles: 'ignore',
etag: false,
extensions: ['htm', 'html'],
index: false,
maxAge: '1d',
redirect: false,
setHeaders: function (res, path, stat) {
res.set('x-timestamp', Date.now());
app.use(express.static('public', options));
上面这段代码将当前路径下的public目录作为静态文件,并且为Cache-Control头部的max-age选项为1天。还有其它一些属性,请对照express.static的文档来理解。
使用express创建的HelloExpress项目的app.js文件里有这样一行代码:
app.use(express.static(path.join(__dirname, 'public')));
这行代码将HelloExpress目录下的public目录作为静态文件交给static中间件来处理,对应的HTTP URI为&/&。path是一个Node.js模块,__dirname是Node.js的全局变量,指向当前运行的js脚本所在的目录。path.join()则用来拼接目录。
有了上面的代码,你就可以在浏览器里访问&&。我们做一点改动,把上面的代码修改成下面这样:
app.use('/static', express.static(path.join(__dirname, 'public')));
上面的代码呢,针对/static路径使用static中间件处理public目录。这时你再用浏览器访问&&就会看到一个404页面,将地址换成&&就可以了。
Express还提供了一个叫做Router的对象,行为很像中间件,你可以把Router直接传递给app.use,像使用中间件那样使用Router。另外你还可以使用router来处理针对GET、POST等的路由,也可以用它来添加中间件,总之你可以将Router看作一个微缩版的app。
下面的代码创建一个Router实例:
var router = express.Router([options]);
然后你就可以像使用app一样使用router(代码来自):
// invoked for any requests passed to this router
router.use(function(req, res, next) {
// .. some logic here .. like any other middleware
// will handle any request that ends in /events
// depends on where the router is "use()'d"
router.get('/events', function(req, res, next) {
定义了router后,也可以将其作为中间件传递给app.use:
app.use('/events', router);
上面这种用法,会针对URL中的&/events&路径应用router,你在router对象上配置的各种路由策略和中间件,都会被在合适的时候应用。
express工具创建的应用,有一个routes目录,下面保存了应用到网站的Router模块,index.js和user.js。这两个模块基本一样,我们研究一下index.js。
下面是index.js的内容:
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/', function(req, res, next) {
res.render('index', { title: 'Express' });
module.exports =
index.js创建了一个Router实例,然后调用router.get为&/&路径应用了路由函数。最后呢使用module.exports将Router对象导出。
下面是app.js里引用到index.js的代码:
var routes = require('./routes/index');
app.use('/', routes);
第一处,require(&./routes/index&)将其作为模块使用,这行代码导入了index.js,并且将index.js导出的router对象保存在变量routes里以供后续使用。注意,上面代码里的routes就是index.js里的router。
第二处代码,把routes作为一个中间件,挂载到了&/&路径上。
前面分析index.js时看到了module.exports的用法。module.exports用来导出一个Node.js模块内的对象,调用者使用require加载模块时,就会获得导出的对象的实例。
我们的index.js导出了Router对象。app.js使用require(&./routes/index&)获取了一个Router实例。
module.exports还有一个辅助用法,即直接使用exports来导出。
exports.signup = function(req, res){
//some code
exports.login = function(req, res){
//some code
上面的代码(假定在users.js文件里)直接使用exports来导出。当使用exports来导出时,你设置给exports的属性和方法,实际上都是module.exports的。这个模块最终导出的是module.exports对象,你使用类似&exports.signup&这种形式设置的方法或属性,调用方在require后都可以直接使用。
使用users模块的代码可能是这样的:
var express = require('express');
var app = express();
var users = require('./routes/users');
app.post('/signup', users.signup);
app.post('/login', users.login);
 1. &什么是router路径,什么是middleware?
我们输入www.baidu.com 来访问百度的主页,浏览器会自动转换为 http://www.baidu.com:80/(省略一些参数)。 http://代表我们同服务器连接使用的是http协议,www.baidu.com 代表的是服务器的主机地址,会被我们的pc通过DNS解析为IP地址。80是默认的应用层端口。/ 即为我们访问的服务器(www.baidu.com)的路径,服务器要对我们访问的这个路径做出响应,采取一定的动作。我们可以把这一过程看做一个路由。
&访问的路径&/&即为router的路径,服务器采取的动作即为middleware,即为一个个特殊的函数。
  2. router路径
&  : 路径为 /test
&&&&&&: 路径同样为/test, ?后面会被服务器理解传给路径的参数。
&  3. Middleware&
An Express application is essentially a stack of middleware which are executed serially.(express应用其实就是由一系列顺序执行的Middleware组成。)
A middleware is a function with access to the request object (req), the response object (res), and the next middleware in line in the request-response cycle of an Express application. It is commonly denoted by a variable named next. Each middleware has the capacity to execute any code, make changes to the request and the reponse object, end the request-response cycle, and call the next middleware in the stack. Since middleware are execute serially, their order of inclusion is important.(中间件其实就是一个访问express应用串入的req,res,nex参数的函数,这个函数可以访问任何通过req,res传入的资源。)
If the current middleware is not ending the request-response cycle, it is important to call next() to pass on the control to the next middleware, else the request will be left hanging.(如果当前中间件没有完成对网页的res响应 ,还可以通过next把router 留给下一个middleware继续执行)
With an optional mount path, middleware can be loaded at the application level or at the router level. Also, a series of middleware functions can be loaded together, creating a sub-stack of middleware system at a mount point.
  路由的产生是通过HTTP的各种方法(GET, POST)产生的,Middleware可以跟router路径跟特定的HTTP方法绑定,也可以跟所有的方法绑定。
  3.1 通过express应用的use(all),把Middleware同router路径上的所有HTTP方法绑定:
1 app.use(function (req, res, next) {
console.log('Time: %d', Date.now());
  3.2&通过express应用的http.verb,把Middleware同router路径上的特定的HTTP方法绑定:
1 app.get('/', function(req, res){
res.send('hello world');
6 app.post('/', function(req, res){
res.send('hello world');
  4. &Express的Router对象
  当express实例的路由越来越多的时候,最好把路由分类独立出去,express的实例(app) 能更好的处理其他逻辑流程。Express的Router对象是一个简化的 app实例,只具有路由相关的功能,包括use, http verbs等等。最后这个Router再通过app的use挂载到app的相关路径下。
1 var express = require('express');
2 var app = express();
3 var router = express.Router();
5 // simple logger for this router's requests
6 // all requests to this router will first hit this middleware
7 router.use(function(req, res, next) {
console.log('%s %s %s', req.method, req.url, req.path);
12 // this will only be invoked if the path ends in /bar
13 router.use('/bar', function(req, res, next) {
// ... maybe some additional /bar logging ...
18 // always invoked
19 router.use(function(req, res, next) {
res.send('Hello World');
23 app.use('/foo', router);
25 app.listen(3000);
  router的路由必须通过app.use和app.verbs 挂载到app上才能被响应。所以上述代码,只有在app捕捉到 /foo路径上的路由时,才能router中定义的路由,虽然router中有针对 '/' 的路由,但是被app中的路由给覆盖了。
附:app.verbs和app.use的路由路径区别:
先看一段测试代码:
var express = require('express');
var app = express();
var router = express.Router();
app.get('/', function(req, res){
console.log('test1');
app.use('/', function(req, res){
console.log('test2');
router.get('/', function(req, res){
console.log('test3');
app.listen(4000);
输入url:&localhost:4000
输出结果:test1
输入url: localhost:4000/hello
输出结果:test2
  结论:app.get挂载&/&的路由只响应跟'/'精确匹配的GET请求。 而app.use挂载的'/'的路由响应所有以'/' 为起始路由的路由,且不限制HTTP访问的方法。以下说明:Mounting a middleware at a path will cause the middleware function to be executed whenever&the base of&the requested path matches the path.
1 app.use([path], [function...], function)
2 Mount the middleware function(s) at the path. If path is not specified, it defaults to "/".
4 Mounting a middleware at a path will cause the middleware function to be executed whenever the base of the requested path matches the path.
摘自CSDN:
摘自博客园:
阅读(...) 评论()如何使用nodejs作为java和前端的中间件_百度知道
如何使用nodejs作为java和前端的中间件
我有更好的答案
npm install handlebars --snpm install express --sThen you can use handlebars as a front-end template and express as the server
为您推荐:
您可能关注的内容
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。在 SegmentFault,学习技能、解决问题
每个月,我们帮助 1000 万的开发者解决各种各样的技术问题。并助力他们在技术能力、职业生涯、影响力上获得提升。
问题对人有帮助,内容完整,我也想知道答案
问题没有实际价值,缺少关键内容,没有改进余地
如题所述,,,,,,,,
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
你这些问题太宽泛,没有具体什么说明,如果从很宽泛的回答你是,只要接口对上,就是可以的。因为包括express本质上也是一些接口。但具体上来说,要看你的具体应用。nodejs在http server 上实现是挺不错的选择,一则开发快速,另一则,与前端可以高度衔接。但如果你的应用有一些特别要求,并且其它的的框架有特别合适的那你也要考虑的。
答案对人有帮助,有参考价值
答案没帮助,是错误的答案,答非所问
你的问题跟“原生js能不能直接用jq插件呢?”一个意思。
同步到新浪微博
分享到微博?
关闭理由:
删除理由:
忽略理由:
推广(招聘、广告、SEO 等)方面的内容
与已有问题重复(请编辑该提问指向已有相同问题)
答非所问,不符合答题要求
宜作评论而非答案
带有人身攻击、辱骂、仇恨等违反条款的内容
无法获得确切结果的问题
非开发直接相关的问题
非技术提问的讨论型问题
其他原因(请补充说明)
我要该,理由是:
在 SegmentFault,学习技能、解决问题
每个月,我们帮助 1000 万的开发者解决各种各样的技术问题。并助力他们在技术能力、职业生涯、影响力上获得提升。如何使用nodejs作为java和前端的中间件_百度知道
如何使用nodejs作为java和前端的中间件
我有更好的答案
npm install handlebars --snpm install express --sThen you can use handlebars as a front-end template and express as the server
采纳率:98%
来自团队:
为您推荐:
其他类似问题
您可能关注的内容
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。NodeJS学习笔记之Connect中间件应用实例 | WEB开发
NodeJS学习笔记之Connect中间件应用实例
一,开篇分析
大家好哦,大熊君又来了,昨天因为有点个人的事没有写博客,今天又出来了一篇,这篇主要是写一个记事本的小应用,前面的文章,
我也介绍过“Connect”中间件的使用以及“Mongodb”的用法,今天就结合这两个中间件,写个实际的例子,不断完善和重构,已达到
充分学习的目的。好了,废话不说了,直接进入主题。
二,需求分析
(1),用户注册,登录功能(没有涉及很复杂的交互场景,注册时会有用户判断是否已存在)。
(2),用户登录成功,进入笔记管理系统的后台(笔记模块的增删改查功能)。
(3),用户可以具有简单的权限划分(管理员,注册用户)。
(4),界面比较简单,以学习为主。
三,开始设计应用(第一部分)
(1),建立用户登录页面,代码如下:
&!doctype html&
&&& &head&
&&&&&&& &title&Bigbear记事本应用登录&/title&
&&&&&&& &meta content="IE=8" http-equiv="X-UA-Compatible"/&
&&&&&&& &meta http-equiv="Content-Type" content="text/ charset=UTF-8"&
&&&&&&& &style type="text/css"&
&&&&&&&&&&& .note-title {
&&&&&&&&&&&&&&& margin-bottom : 45
&&&&&&&&&&&&&&& background : #6699
&&&&&&&&&&&&&&& font-size : 14
&&&&&&&&&&&&&&& font-weight :
&&&&&&&&&&&&&&& color : #
&&&&&&&&&&&&&&& font-family:
&&&&&&&&&&&&&&& height : 24
&&&&&&&&&&&&&&& line-height : 24
&&&&&&&&&&& }
&&&&&&&&&&& a {
&&&&&&&&&&&&&&& color : #336699;
&&&&&&&&&&&&&&& font-family:
&&&&&&&&&&&&&&& font-size : 14
&&&&&&&&&&&&&&& font-weight :
&&&&&&&&&&& }
&&&&&&& &/style&
&&&&&&& &script src="js/index.js"&&/script&
&&& &/head&
&&& &body&
&&&&&&& &div class="note-title"&Bigbear记事本应用登录&/div&
&&&&&&&&&&& &form action="/login" method="post"&
&&&&&&&&&&&&&&& &span&用户名:&/span&&input type="text" name="name" /&&br/&&br/&
&&&&&&&&&&&&&&& &span&密&&码:&/span&&input type="password" name="password" /&
&&&&&&&&&&&&&&& &input type="submit" value="登录" /&
&&&&&&&&&&&&&&& &a href="reg.html"&我要注册&/a&
&&&&&&&&&&& &/form&
&&& &/body&
  效果图:
(2),建立用户注册页面,代码如下:
&&!doctype html&
&&&& &head&
&&&&&&&& &title&Bigbear记事本应用注册&/title&
&&&&&&&& &meta content="IE=8" http-equiv="X-UA-Compatible"/&
&&&&&&&& &meta http-equiv="Content-Type" content="text/ charset=UTF-8"&
&&&&&&&& &style type="text/css"&
&&&&&&&&&&&& .note-title {
&&&&&&&&&&&&&&&& margin-bottom : 45
&&&&&&&&&&&&&&&& background : #ff3300 ;
&&&&&&&&&&&&&&&& font-size : 14
&&&&&&&&&&&&&&&& font-weight :
&&&&&&&&&&&&&&&& color : #
&&&&&&&&&&&&&&&& font-family:
&&&&&&&&&&&&&&&& height : 24
&&&&&&&&&&&&&&&& line-height : 24
&&&&&&&&&&&& }
&&&&&&&& &/style&
&&&&&&&& &script src="js/index.js"&&/script&
&&&& &/head&
&&&& &body&
&&&&&&&& &div class="note-title"&Bigbear记事本应用注册&/div&
&&&&&&&&&&&& &form action="/reg" method="post"&
&&&&&&&&&&&&&&&& &span&用户名:&/span&&input type="text" name="name" /&&br/&&br/&
&&&&&&&&&&&&&&&& &span&密&&码:&/span&&input type="password" name="password" /&&br/&&br/&
&&&&&&&&&&&&&&&& &input type="submit" value="注册" /&
&&&&&&&&&&&& &/form&
&&&& &/body&
  效果图:
(3),建立“Mongodb”连接代码,如下:
&var mongodb = require("mongodb") ;
&var server = new mongodb.Server("localhost",27017,{
&&&& auto_reconnect : true
&var conn = new mongodb.Db("bb",server,{
&&&& safe : true
&conn.open(function(error,db){
&&&& if(error)
&&&& console.info("mongodb connected !") ;
&exports = module.exports =
(4),建立模型实体类“User”,如下:
&var conn = require("../conn") ;
&function User(user){
&&&& this.name = user["name"] ;
&&&& this.password = user["password"] ;
&User.prototype.save = function(callback){
&&&& var that =
&&&& conn.collection("users",{
&&&&&&&& safe : true
&&&& },function(error,collection){
&&&&&&&& if(error) return conn.close() ;
&&&&&&&& collection.findOne({&& // 判断此用户是否存在
&&&&&&&&&&&& name : that.name
&&&&&&&& },function(error,user){
&&&&&&&&&&&& if(error) return conn.close() ;
&&&&&&&&&&&& if(!user){
&&&&&&&&&&&&&&&& collection.insert({
&&&&&&&&&&&&&&&&&&&& name : that.name + "" ,
&&&&&&&&&&&&&&&&&&&& password : that.password + ""
&&&&&&&&&&&&&&&& },{
&&&&&&&&&&&&&&&&&&&& safe : true
&&&&&&&&&&&&&&&& },function(error,user){
&&&&&&&&&&&&&&&&&&&& if(error) return conn.close() ;
&&&&&&&&&&&&&&&&&&&& callback && callback(user) ;
&&&&&&&&&&&&&&&&&&&& conn.close() ;
&&&&&&&&&&&&&&&& }) ;&&&&&&&
&&&&&&&&&&&& }
&&&&&&&&&&&& else{
&&&&&&&&&&&&&&&& callback("User has registed !") ;
&&&&&&&&&&&& }
&&&&&&&& }) ;
&User.login = function(name,password,callback){
&&&& conn.collection("users",{
&&&&&&&& safe : true
&&&& },function(error,collection){
&&&&&&&& if(error) return conn.close() ;
&&&&&&&& collection.findOne({
&&&&&&&&&&&& name : name ,
&&&&&&&&&&&& password : password
&&&&&&&& },function(error,user){
&&&&&&&&&&&& if(error) return conn.close() ;
&&&&&&&&&&&& callback && callback(user) ;
&&&&&&&&&&&& conn.close() ;
&&&&&&&& }) ;
&exports = module.exports = U
  效果图:
(5),建立应用程序“app”,如下:
&// app.js
&var connect = require("./lib/connect") ;
&var user = require("./models/user") ;
&var app = connect.createServer() ;
&app .use(connect.logger("dev"))
&.use(connect.query())
&.use(connect.bodyParser())
&.use(connect.cookieParser())
&.use(connect.static(__dirname + "/views"))
&.use(connect.static(__dirname + "/public"))
&.use("/login",function(request,response,next){
&&&& var name = request.body["name"] ;
&&&& var password = request.body["password"] ;
&&&& user.login(name,password,function(user){
&&&&&&&& if(user){
&&&&&&&&&&&& response.end("Welcome to:" + user["name"] + " ^_^ ... ...") ;&&&
&&&&&&&& }
&&&&&&&& else{
&&&&&&&&&&&& response.end("User:" + name + " Not Register !")&&& ;
&&&&&&&& }
&.use("/reg",function(request,response,next){
&&&& var name = request.body["name"] ;
&&&& var password = request.body["password"] ;
&&&& new user({
&&&&&&&& name : name ,
&&&&&&&& password : password
&&&& }).save(function(user){
&&&&&&&& if(user && user["name"]){
&&&&&&&&   response.end("User:" + name + "Register Done !")&&& ;&&&
&&&&&&&& }
&&&&&&&& else{
&&&&&&&&   response.end("User: " + name + "has registed !") ;&
&&&&&&&& }
&.listen(8888,function(){
&&&& console.log("Web Server Running On Port ---& 8888 .") ;
  说明一下:
    (1)“connect.query()”------处理“Get”请求参数解析。
    (2)“connect.bodyParser()”------处理“Post”请求参数解析。
    (3)“connect.static(__dirname + "/views"),connect.static(__dirname + "/public")”
     分别代表模板视图“html”以及静态资源如“js,css,jpg,gif”的资源目录。
     以下是这个应用的目录结构:
四,总结一下
  (1),掌握NodeJs操作数据库的基本操作语句。
  (2),划分层级,如模型,视图,路由。
  (3),不断优化和修改本文的例子(比如注册验证用户是否存在,可以独立出“UserManager”做一层代理完成用户验证和保存的动作)。
  (4),明天继续完成后续的功能,尽请期待。}

我要回帖

更多关于 nodejs作为java中间件 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信