- 博客(24)
- 收藏
- 关注
翻译 nodejs中cookie的基本使用
/** 1、安装 npm install cookie-parser --save* 2、引入var cookieParser =* 3、设置中间件 app.use()* 4、设置cookie HttpOnly默认fals不允许客户端脚本访问,* 允许后端进行访问,也允许nodejs进行访问,但不允许前端的js代码进行访问* 5、获取cookie**...
2019-01-25 11:46:19 10232 4
翻译 express中间件 body-parser中间件
1、目录结构2、依赖"dependencies": { "body-parser": "^1.18.3", "ejs": "^2.6.1", "express": "^4.16.4" }3、01express应用级中间件.jsvar express = require('express')//引入var app =
2019-01-24 21:28:16 342
翻译 express_ejs路由
1、目录结构2、news.ejs<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <title></title>
2019-01-24 20:18:11 349
翻译 nodejs操作mongodb
1、这里package.json的依赖版本为"dependencies": { "ejs": "^2.6.1", "mongodb": "^3.1.12"}2、目录结构3、01nodejs_mongodb.js(实现增加,修改和删除)var http = require('http')var ejs = require('ejs')var app = requ...
2019-01-23 23:23:14 234
翻译 MongoDB增删查改命令
主讲教师:(大地) 删除数据库,删除当前所在的数据库db.dropDatabase(); 删除集合,删除指定的集合 删除表删除集合 db.COLLECTION_NAME.drop() db.user.drop() 1、查找命令//查找name等于zhangsan且age等于20的数据db.user.find("name":"zhangsan","age": ...
2019-01-23 11:59:35 271 2
翻译 配置MongoDB服务,让mongod自启动
(前提是首先配置好mongodb的环境变量。)1、目录结构即在D盘的根目录创建data文件夹,在data文件夹内部分别创建db和log文件夹,以及mongod.cfg文件。2、mongod.cfg文件内容logpath=D:\data\log\mongod.loglogappend=truedbpath=D:\data\dbdirectoryperdb=truep...
2019-01-23 10:38:41 932
翻译 模拟express路由封装
1、目录结构2、express_router.jsvar url = require('url')function changeRes(res){ res.send=function(data){ res.writeHead(200,{"Content-Type":"text/html;charset='utf-8'"}) res.end(d...
2019-01-22 21:41:30 520
翻译 仿照express的路由
1、示例代码05router_express.js(粗略)var G = [];var app = function(req,res){//定义函数app if(G['login']){//判断方法是否存在 G['login'](req,res); /*执行注册的方法*/ }}//定义一个get方法app.get=function(string...
2019-01-22 16:14:38 136
翻译 nodejs模块化方法封装路由
1、代码目录结构2、02router.jsvar model = require('./model/model')var http = require('http')var url = require('url')http.createServer(function(req,res){ res.writeHead(200,{"Content-Type":"text/ht...
2019-01-22 13:46:17 913
翻译 nodejs静态文件托管以及路由
1、新建文件router.js//fs模块var fs = require('fs');//path模块var path = require('path');/*nodejs自带的模块*///url模块var url = require('url');var getMime = function(extname, callback) { /*获取后缀名的方法*/ fs...
2019-01-21 16:37:45 688
翻译 nodejs通过事件驱动获取异步函数中的数据
1、目录结构2、getmimefromfile_events.js//这是一个函数exports.getMime=function(fs,extname,EventEmitter){ /*获取后缀名的方法*/ //.html console.log('1'); fs.readFile('./mime.json',function(err,data){ ...
2019-01-21 14:53:05 256
翻译 nodejs 通过回调函数获取异步函数中的数据
1、目录结构2、mime.json{ ".323":"text/h323" , ".3gp":"video/3gpp" , ".aab":"application/x-authoware-bin" , ".aam":"application/x-authoware-map" ,.......此处略去四百多行 "
2019-01-21 14:19:13 2910 1
翻译 nodejs非阻塞IO之 回调函数
var fs = require('fs');function getMime(callback){ fs.readFile('mime.json',(err,data)=>{ //console.log(data.toString()); callback(data);//在异步调用的内部 });}getMime(functio...
2019-01-20 23:20:44 312
翻译 nodejs静态Web服务
//引入http模块var http=require('http');//fs模块var fs=require('fs');//path模块var path=require('path'); /*nodejs自带的模块*/var mimeModel=require('./model/getmime.js');//console.log(mime.getMime('.css'));...
2019-01-20 22:29:21 573
翻译 Spring Web MVC示例。
1、项目目录结构。其实现在只关注spring-webmvc模块。2、将spring-webmvc模块展开之后,该模块的目录结构如下图。3、src目录完全展开如下图所示。4、app-context.xml文件内容:<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spring...
2019-01-11 16:52:29 481
翻译 创建Spring应用上下文
1、启动类package com.imooc.springapplication;import org.springframework.boot.WebApplicationType;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.boot.bu...
2019-01-09 13:00:05 454
翻译 监听spring boot事件
1、spring.factoriescom.imooc.springapplication.listener.BeforeConfigFileApplicationListener2、application.propertiesname = 小马哥3、BeforeConfigFileApplicationListenerpackage com.imooc.springap...
2019-01-09 10:54:28 198
翻译 SpringApplicationRunListener(运行监听器)
1、spring.factories# SpringApplicationRunListenerorg.springframework.boot.SpringApplicationRunListener=\com.imooc.springapplication.run.HelloWorldSpringApplicationRunListener2、HelloWorldSpringAp...
2019-01-09 08:40:29 1287
翻译 Spring framework中运行监听器事件监听器编程模型
1、引导类package com.imooc.springapplication;import org.springframework.context.ApplicationEvent;import org.springframework.context.annotation.AnnotationConfigApplicationContext;public class Sprin...
2019-01-08 22:55:40 149
翻译 加载应用事件监听器
1、spring.factoriesorg.springframework.context.ApplicationListener=\com.imooc.springapplication.listener.AfterHelloWorldApplicationListener,\com.imooc.springapplication.listener.HelloWorldApplicat...
2019-01-08 21:11:34 138
翻译 加载应用上下文初始器
1、spring.factories# Initializersorg.springframework.context.ApplicationContextInitializer=\com.imooc.springapplication.context.AfterHelloWorldApplicationContextInitializer,\com.imooc.springappli...
2019-01-08 19:53:14 165 3
翻译 自定义自动装配
1、spring.factories# Auto Configureorg.springframework.boot.autoconfigure.EnableAutoConfiguration=\com.imooc.diveinspringbootzhujie.configuration.HelloWorldAutoConfiguration2、引导类package com...
2019-01-07 22:43:37 206
翻译 spring @Enable 模块装配
1、定义注解package com.imooc.diveinspringbootzhujie.anotation;import org.springframework.context.annotation.Import;import java.lang.annotation.*;@Target(ElementType.TYPE)@Retention(RetentionPoli...
2019-01-07 21:57:28 208
原创 基于编程方式实现条件装配
1、定义接口package com.imooc.diveinspringbootzhujie.condition;import org.springframework.context.annotation.Conditional;import java.lang.annotation.*;@Retention(RetentionPolicy.RUNTIME)@...
2019-01-07 20:55:29 134
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人