后端
|
1 2 3 4 5 6 7 8 9 10 11 |
// POST api/<controller> public string Post([FromBody]List<User> value) { StringBuilder sb = new StringBuilder(); foreach (User user in value) { sb.AppendLine(user.Username); } return sb.ToString(); } |
前端
|
1 2 3 4 5 6 7 8 |
$.ajax({ method: "Post", url: "http://localhost:37085/api/ValList", data: { <strong>"":</strong> [{ "Id": 1, "Username": "w3cnet" }] }, success: function(result) { console.log(result); } }); |
View Details
1. Invalid location of tag (form) form 应该写到table外面去,form标签只能嵌套进入div等行级元素中,放进块元素会报invalid。 2. Invalid location of tag (style) style应该写在head里面。 3. Invalid location of tag (script) script应该写到body,head里面。 4.Attribute name(Name) uses wrong case character 虽说HTML不区分大小写,但是在Myeclipse里面,大写的话就报错,所以,还是乖乖的改成小写吧。 5. Invalid location of tag (div) 这个错误是因为div的标签使用不当,需要更换为<span>标签 from:https://blog.csdn.net/zalion/article/details/23932731
View Details一、项目简介 基于Spring+SpringMVC+Mybatis分布式敏捷开发系统架构,提供整套公共微服务服务模块:内容管理、支付中心、用户管理(包括第三方)、微信平台、存储系统、配置中心、日志分析、任务和通知等,支持服务治理、监控和追踪,努力为中小型企业打造全方位J2EE企业级开发解决方案。目前已经累计获得10000+的Star,受到了广大程序员的密切关注! 由于该项目框架采用的技术点比较多,新手入门会有一定的困难,所以笔者整理资料写了本篇环境搭建指南,希望能够帮助大家把环境快速的搭建起来。 oschina地址:https://gitee.com/shuzheng/zheng github地址:https://github.com/shuzheng/zheng 二、工具下载 JDK官方下载地址 | 老版本JDK下载地址 TortoiseGit: 下载地址 | 安装与配置教程 Git客户端官网下载太慢,最新版本: Git-2.14.1-64-bit 客户端下载 MySQL数据库: 下载与安装5.7教程 | 百度经验 (电脑可以装多个MySQL,端口不一样即可) MySQL客户端: Navicat for MySQL下载、安装与破解 Maven官方下载地址 下载最新的apache-maven-3.5.0-bin.zip解压到本地目录,打开/conf/settings.xml进行编辑,修改本地的仓库地址,默认的Maven镜像下载速度十分感人,强烈建议使用阿里云的,可以享受飞一般的速度。精简版的配置如下,以供参考:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> <!-- 仓库地址 --> <localRepository>E:/maven/repository</localRepository> <pluginGroups></pluginGroups> <proxies></proxies> <servers></servers> <mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors> <profiles></profiles> </settings> |
Redis官方下载地址 : Linux版本 | Windows教程 | 安装教程2 最新版本Redis3.2配置文件redis.conf详细说明 Redis客户端Redis Desktop Manager: 官网下载 | PC6快速下载 ActiveMQ: 官方最新版下载地址 | ActiveMQ基本配置与示例演示 ZooKeeper:官方下载地址 | Zookeeper 安装和配置 Nginx:官方下载地址 | Nginx安装与配置 | 负载均衡 dubbo-admin-2.5.4: 下载地址 (需使用jdk1.7) | dubbo-admin管理平台搭建 三、导入项目 推荐使用IntelliJ IDEA, 安装教程: Windows7下安装与破解IntelliJ IDEA2017 IDEA使用Git在线导入,具体操作可以百度一下,或者File ->Open进行导入项目。 导入完毕,IDEA右侧Maven Projects找到zheng->Lifecycle->install 点击运行,在本地Repository中安装依赖的jar包,编译时间有点长,请耐心等待。 加入作者建立的QQ群,群内含各种工具、文档、视频教程下载,还有热心群友答疑解惑。 四、环境搭建 QQ群内提供了环境搭建文档和视频【点击下载】 ,未能加入群?没关系,参考本篇指南就够了。 修改项目配置文件里mysql和Redis密码: 各dao模块和rpc-service模块的redis.properties、jdbc.properties、generator.properties数据库连接等配置信息,其中master.redis.password、master.jdbc.password、slave.jdbc.password、generator.jdbc.password里密码值使用了AES加密,请使用com.zheng.common.util.AESUtil工具类修改这些值。项目里默认的是空字符串加密后密文:FNFl9F2O2Skb8yoKM0jhHA==。 配置hosts, 打开文件C:\Windows\System32\drivers\etc\hosts,增加如下配置:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
127.0.0.1 ui.zhangshuzheng.cn 127.0.0.1 upms.zhangshuzheng.cn 127.0.0.1 cms.zhangshuzheng.cn 127.0.0.1 pay.zhangshuzheng.cn 127.0.0.1 ucenter.zhangshuzheng.cn 127.0.0.1 wechat.zhangshuzheng.cn 127.0.0.1 api.zhangshuzheng.cn 127.0.0.1 oss.zhangshuzheng.cn 127.0.0.1 config.zhangshuzheng.cn 127.0.0.1 zkserver 127.0.0.1 rdserver 127.0.0.1 dbserver 127.0.0.1 mqserver |
配置Nginx:进入项目zheng/project-tools/nginx/,把里面的nginx.conf和servers复制到Nginx安装路径的conf目录下,比如我的D:\Java\nginx-1.12.1\conf,然后进入servers文件夹修改zheng-ui.conf,root路径修改到zheng-ui的根目录,详细的配置参考下面:
|
1 2 3 4 5 6 7 8 9 10 |
server { listen 1000 default; server_name localhost; location / { root E:/workspace/IntelliJIDEA2017/zheng/zheng-ui/; index index.html index.htm; add_header Access-Control-Allow-Origin *; } access_log logs/zheng-ui.access.log; } |
五、启动项目 六、见证奇迹的时刻 访问 http://upms.zhangshuzheng.cn:1111/,默认帐号密码:admin/123456 内容管理系统CMS访问 http://cms.zhangshuzheng.cn:2224,页面如下: 至此,项目的环境搭建大功告成,为了同学们能够快速入门,搜罗了不少资料,如有帮助请点赞。 现在已经将近凌晨一点了,洗洗睡喽! from:https://my.oschina.net/yzuzhang/blog/1538555
View DetailsDubbo是阿里巴巴公司开源的一个高性能优秀的服务框架,使得应用可通过高性能的 RPC 实现服务的输出和输入功能,可以和Spring框架无缝集成。 主要核心部件 Remoting: 网络通信框架,实现了 sync-over-async 和 request-response 消息机制. RPC: 一个远程过程调用的抽象,支持负载均衡、容灾和集群功能 Registry: 服务目录框架用于服务的注册和服务事件发布和订阅 工作原理 Provider 暴露服务方称之为“服务提供者”。 Consumer 调用远程服务方称之为“服务消费者”。 Registry 服务注册与发现的中心目录服务称之为“服务注册中心”。 Monitor 统计服务的调用次数和调用时间的日志服务称之为“服务监控中心”。 (1) 连通性: 注册中心负责服务地址的注册与查找,相当于目录服务,服务提供者和消费者只在启动时与注册中心交互,注册中心不转发请求,压力较小 监控中心负责统计各服务调用次数,调用时间等,统计先在内存汇总后每分钟一次发送到监控中心服务器,并以报表展示 服务提供者向注册中心注册其提供的服务,并汇报调用时间到监控中心,此时间不包含网络开销 服务消费者向注册中心获取服务提供者地址列表,并根据负载算法直接调用提供者,同时汇报调用时间到监控中心,此时间包含网络开销 注册中心,服务提供者,服务消费者三者之间均为长连接,监控中心除外 注册中心通过长连接感知服务提供者的存在,服务提供者宕机,注册中心将立即推送事件通知消费者 注册中心和监控中心全部宕机,不影响已运行的提供者和消费者,消费者在本地缓存了提供者列表 注册中心和监控中心都是可选的,服务消费者可以直连服务提供者 (2) 健壮性: 监控中心宕掉不影响使用,只是丢失部分采样数据 数据库宕掉后,注册中心仍能通过缓存提供服务列表查询,但不能注册新服务 注册中心对等集群,任意一台宕掉后,将自动切换到另一台 注册中心全部宕掉后,服务提供者和服务消费者仍能通过本地缓存通讯 服务提供者无状态,任意一台宕掉后,不影响使用 服务提供者全部宕掉后,服务消费者应用将无法使用,并无限次重连等待服务提供者恢复 (3) 伸缩性: 注册中心为对等集群,可动态增加机器部署实例,所有客户端将自动发现新的注册中心 服务提供者无状态,可动态增加机器部署实例,注册中心将推送新的服务提供者信息给消费者 例子 服务端 定义一个Service Interface:(HelloService.java) 1 2 3 4 5 6 7 8 package com.alibaba.hello.api; public interface HelloService { String sayHello(String name); } 接口的实现类:(HelloServiceImpl.java) 1 2 3 4 5 6 7 package com.alibaba.hello.impl; import com.alibaba.hello.api.HelloService; public class HelloServiceImpl implements HelloService{ public String sayHello(String name){ return "Hello" + name; } } Spring配置:(provider.xml) 1 2 3 4 5 6 7 8 […]
View Details导入了一个工程,编译什么的都还好,但是报了一个XML的错误。 cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'dubbo:application'. 具体错误如下: Multiple annotations found at this line: – cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'dubbo:application'. – schema_reference.4: Failed to read schema document 'http://code.alibabatech.com/schema/dubbo/dubbo.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not <xsd:schema>. 根据错误提示,有可能是http://code.alibabatech.com/schema/dubbo/dubbo.xsd这个文档找不到或者打不开,于是百度了一下,发现类似问题的问还是比较多的,比较轻松找到解决办法。大致的思路是,到网上下载一个dubbo.xsd文件,其实在dubbo的jar包里就有,直接解压出来就好,放到本地目录,然后在Eclipse里配置上关联关系,让Eclipse能找到这个文件即可。 1、下载一个dubbo.xsd文件; 2、在windows->preferrence->xml->xmlcatalogadd->catalog entry ->file system 选择刚刚下载的文件路径; 3、修改key值和配置文件的http://code.alibabatech.com/schema/dubbo/dubbo.xsd 相同保存。 4、在xml文件右键validate就可以k解决了。 后记:有其它的xsd文件找不到的情况,也可以按照类似的方法解决。 from:https://blog.csdn.net/ddshang/article/details/72772640
View Details|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
var http = require('http'); var moment = require('moment'); process.env.TZ = "Asia/Shanghai"; http.createServer(function (request, response) { var sql = require('mssql'); sql.close(); //连接方式1:"mssql://用户名:密码@ip地址(无需端口号)/SqlServer名/数据库名称" //连接方式2:"mssql://用户名:密码@ip地址:1433(默认端口号)/数据库名称" sql.connect("mssql://sa:s1a2@127.0.0.1/DBNAME").then(function () { new sql.Request().query('select top 10 * from TABLENAME').then(function (result) { response.writeHead(200, { "content-type": "text/html;charset=utf-8;" }); result.recordset.forEach(row => { response.write(row.ID + ' - ' + row.Name + ' - ' + moment(row.DateTime).utc().format("YYYY-MM-DD HH:mm:ss") + "<br>"); }); response.end(); }).catch(function (err) { console.log(err); }); }).catch(function (err) { console.log(err); }); }).listen(8886); |
引用: https://blog.csdn.net/u010668495/article/details/50817136 https://www.npmjs.com/package/mssql https://www.cnblogs.com/cyfhykx/p/6224078.html
View Details今天开始学习Node.js,在写一个文件上传的功能时候,调用fs.renameSync方法错误 出错代码所在如下:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
1 function upload(response,request){ 2 console.log("upload called"); 3 var form = new formidable.IncomingForm(); 4 console.log("about to parse"); 5 form.parse(request, function(error, fields, files) { 6 console.log("parsing done"); 7 fs.renameSync(files.upload.path, "./tmp/test.jpg"); 8 response.writeHead(200, {"Content-Type": "text/html"}); 9 response.write("received image:<br/>"); 10 response.write("<img src='/show' />"); 11 response.end(); 12 }); 13 } |
大致分析后,预计是因为跨磁盘分区移动或操作文件会有权限问题。 下面提供两种解决办法: 方法一: 主要利用fs的createReadStream、createWriteSream和unlinkSync方法 具体代码如下:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
1 function upload(response,request){ 2 console.log("upload called"); 3 var form = new formidable.IncomingForm(); 4 console.log("about to parse"); 5 form.parse(request, function(error, fields, files) { 6 console.log("parsing done"); 7 // fs.renameSync(files.upload.path, "./tmp/test.jpg"); 8 <strong>var readStream=fs.createReadStream(files.upload.path); 9 var writeStream=fs.createWriteStream("./tmp/test.jpg"); 10 readStream.pipe(writeStream); 11 readStream.on('end',function(){ 12 fs.unlinkSync(files.upload.path); 13 }); </strong>14 response.writeHead(200, {"Content-Type": "text/html"}); 15 response.write("received image:<br/>"); 16 response.write("<img src='/show' />"); 17 response.end(); 18 }); 19 } |
PS:我用的node版本是0.10.69,如果使用的是0.6以下的版本,可以使用util.pump 相应代码只需将上面的代码中readStream.on处改成:(注意引入util模块)
|
1 2 3 |
util.pump(readStream,writeStream, function() { fs.unlinkSync('files.upload.path'); }); |
方法二: 这种就简洁很多了 添加一个 form.uploadDir=’tmp' 即可(写一个临时路径)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
1 function upload(response,request){ 2 console.log("upload called"); 3 var form = new formidable.IncomingForm(); 4 <strong> form.uploadDir='tmp'; </strong> 5 6 console.log("about to parse"); 7 form.parse(request, function(error, fields, files) { 8 console.log("parsing done"); 9 fs.renameSync(files.upload.path, "./tmp/test.jpg"); 10 response.writeHead(200, {"Content-Type": "text/html"}); 11 response.write("received image:<br/>"); 12 response.write("<img src='/show' />"); 13 response.end(); 14 }); 15 } 16 |
解决问题后,就可以很开心的继续我的Node学习了,感觉路还很长啊 PS:附上两个有关Node文件上传的帖子,个人觉得挺不错的,来源都是cnode nodejs-post文件上传原理详解 node-formidable详解 from:https://www.cnblogs.com/glczero/archive/2014/08/23/3932024.html
View Details如果VS2013,在打开解决方案时,报如下错误: “未找到与约束 ContractName Microsoft.Internal.VisualStudio.PlatformUI.ISolutionAttachedCollectionService RequiredTypeIdentity Microsoft.Internal.VisualStudio.PlatformUI.ISolutionAttachedCollectionService 匹配的导出” 导致项目无法打开以及VS无法关闭。 解决方法: 1.关闭VS; 2.去C:/Users/<your users name>/AppData/Local/Microsoft/VisualStudio/12.0/ComponentModelCache文件夹下删除所有文件及文件夹; 3.重新打开VS即可。 如果是vs2012的话 方法一: 可以尝试删除最近更新的windows补丁更新,主要是关于.net Framework的。 如果方法一行不通,可以尝试方法二,或直接用方法二解决。 方法二: 安装微软的windows补丁 KB2781514(官网:https://www.microsoft.com/zh-cn/download/details.aspx?id=36020) ,补丁主要解决“在 .NET Framework 4.5 更新之后,Visual Studio 用户可能无法打开或创建 C++ 或 JavaScript 文件或项目。” from:https://www.cnblogs.com/ChineseMoonGod/p/5687521.html
View Details在前面《Nginx服务器开箱体验》 一文中我们从开箱到体验,感受了一下Nginx服务器的魅力。Nginx是轻量级的高性能Web服务器,提供了诸如HTTP代理和反向代理、负载均衡、缓存等一系列重要特性,因而在实践之中使用广泛,笔者也在学习和实践之中。
在本文中,我们继续延续前文,从前文给出的一份示例配置清单开始,详解一下Nginx服务器的各种配置指令的作用和用法。
使用说明: 在【Tools】-【Execute Commands】-【Edit/Run Script】 下。输入下面你要选择的语句即可,也可以保存起来,以便下次使用,后缀为.vbs。 需要注意的问题是:运行语句时必须在Module模式下,如果是导出报表时执行会出现错误提示。 1.Name转到Comment注释字段。一般情况下只填写NAME,COMMENT可以运行语句自动生成。 将该语句保存为name2comment.vbs
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
Option Explicit ValidationMode = True InteractiveMode = im_Batch Dim mdl ' the current model ' get the current active model Set mdl = ActiveModel If (mdl Is Nothing) Then MsgBox "There is no current Model " ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then MsgBox "The current model is not an Physical Data model. " Else ProcessFolder mdl End If ' This routine copy name into comment for each table, each column and each view ' of the current folder Private sub ProcessFolder(folder) Dim Tab 'running table for each Tab in folder.tables if not tab.isShortcut then if trim(tab.comment)="" then'如果有表的注释,则不改变它.如果没有表注释.则把name添加到注释里面. tab.comment = tab.name end if Dim col ' running column for each col in tab.columns if trim(col.comment)="" then '如果col的comment为空,则填入name,如果已有注释,则不添加;这样可以避免已有注释丢失. col.comment= col.name end if next end if next Dim view 'running view for each view in folder.Views if not view.isShortcut and trim(view.comment)="" then view.comment = view.name end if next ' go into the sub-packages Dim f ' running folder For Each f In folder.Packages if not f.IsShortcut then ProcessFolder f end if Next end sub |
2.将Comment内容保存到NAME中,comment2name.vbs 实习互换。语句为:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
Option Explicit ValidationMode = True InteractiveMode = im_Batch Dim mdl ' the current model ' get the current active model Set mdl = ActiveModel If (mdl Is Nothing) Then MsgBox "There is no current Model " ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then MsgBox "The current model is not an Physical Data model. " Else ProcessFolder mdl End If Private sub ProcessFolder(folder) On Error Resume Next Dim Tab 'running table for each Tab in folder.tables if not tab.isShortcut then tab.name = tab.comment Dim col ' running column for each col in tab.columns if col.comment="" then else col.name= col.comment end if next end if next Dim view 'running view for each view in folder.Views if not view.isShortcut then view.name = view.comment end if next ' go into the sub-packages Dim f ' running folder For Each f In folder.Packages if not f.IsShortcut then ProcessFolder f end if Next end sub |
from:https://www.cnblogs.com/netsql/archive/2010/05/24/1742734.html
View Details