这是我的简单形式:
<form id="loginformA" action="userlogin" method="post">
<div>
<label for="email">Email: </label>
<input type="text" id="email" name="email"></input>
</div>
<input type="submit" value="Submit"></input>
</form>
Run Code Online (Sandbox Code Playgroud)
这是我的Express.js /Node.js代码:
app.post('/userlogin', function(sReq, sRes){
var email = sReq.query.email.;
}
Run Code Online (Sandbox Code Playgroud)
我试过sReq.query.email或sReq.query['email']或sReq.params['email']等他们都没有工作.他们都回来了undefined.
当我改为Get电话时,它有效,所以..任何想法?
没有本地访问服务器,有没有办法将MySQL数据库(包含内容和没有内容)复制/克隆到另一个不使用mysqldump?
我目前正在使用MySQL 4.0.
我收到以下错误快递:
Error: request entity too large
at module.exports (/Users/michaeljames/Documents/Projects/Proj/mean/node_modules/express/node_modules/connect/node_modules/raw-body/index.js:16:15)
at json (/Users/michaeljames/Documents/Projects/Proj/mean/node_modules/express/node_modules/connect/lib/middleware/json.js:60:5)
at Object.bodyParser [as handle] (/Users/michaeljames/Documents/Projects/Proj/mean/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:53:5)
at next (/Users/michaeljames/Documents/Projects/Proj/mean/node_modules/express/node_modules/connect/lib/proto.js:193:15)
at Object.cookieParser [as handle] (/Users/michaeljames/Documents/Projects/Proj/mean/node_modules/express/node_modules/connect/lib/middleware/cookieParser.js:60:5)
at next (/Users/michaeljames/Documents/Projects/Proj/mean/node_modules/express/node_modules/connect/lib/proto.js:193:15)
at Object.logger (/Users/michaeljames/Documents/Projects/Proj/mean/node_modules/express/node_modules/connect/lib/middleware/logger.js:158:5)
at next (/Users/michaeljames/Documents/Projects/Proj/mean/node_modules/express/node_modules/connect/lib/proto.js:193:15)
at Object.staticMiddleware [as handle] (/Users/michaeljames/Documents/Projects/Proj/mean/node_modules/express/node_modules/connect/lib/middleware/static.js:55:61)
at next (/Users/michaeljames/Documents/Projects/Proj/mean/node_modules/express/node_modules/connect/lib/proto.js:193:15)
TypeError: /Users/michaeljames/Documents/Projects/Proj/mean/app/views/includes/foot.jade:31
29| script(type="text/javascript", src="/js/socketio/connect.js")
30|
> 31| if (req.host='localhost')
32| //Livereload script rendered
33| script(type='text/javascript', src='http://localhost:35729/livereload.js')
34|
Cannot set property 'host' of undefined
at eval (eval at <anonymous> (/Users/michaeljames/Documents/Projects/Proj/mean/node_modules/jade/lib/jade.js:152:8), <anonymous>:273:15)
at /Users/michaeljames/Documents/Projects/Proj/mean/node_modules/jade/lib/jade.js:153:35
at Object.exports.render (/Users/michaeljames/Documents/Projects/Proj/mean/node_modules/jade/lib/jade.js:197:10)
at Object.exports.renderFile …Run Code Online (Sandbox Code Playgroud) 你能解释一下JavaScript中封装的匿名函数语法背后的原因吗?为什么这样做:(function(){})();但这不是:function(){}();?
在JavaScript中,可以创建一个这样的命名函数:
function twoPlusTwo(){
alert(2 + 2);
}
twoPlusTwo();
Run Code Online (Sandbox Code Playgroud)
您还可以创建匿名函数并将其分配给变量:
var twoPlusTwo = function(){
alert(2 + 2);
};
twoPlusTwo();
Run Code Online (Sandbox Code Playgroud)
您可以通过创建匿名函数来封装代码块,然后将其包装在括号中并立即执行:
(function(){
alert(2 + 2);
})();
Run Code Online (Sandbox Code Playgroud)
这在创建模块化脚本时非常有用,可以避免使当前作用域或全局作用域混乱,并且可能存在冲突的变量 - 例如Greasemonkey脚本,jQuery插件等.
现在,我理解为什么会这样.括号包含内容并仅公开结果(我确定有更好的方法来描述),例如with (2 + 2) === 4.
但我不明白为什么这也不起作用:
function(){
alert(2 + 2);
}();
Run Code Online (Sandbox Code Playgroud)
你能解释一下吗?
它更多的是关于python列表理解语法.我有一个列表理解,可以生成给定范围的奇数列表:
[x for x in range(1, 10) if x % 2]
Run Code Online (Sandbox Code Playgroud)
这是一个过滤器 - 我有一个源列表,我删除偶数(if x % 2).我想在这里使用if-then-else之类的东西.以下代码失败:
>>> [x for x in range(1, 10) if x % 2 else x * 100]
File "<stdin>", line 1
[x for x in range(1, 10) if x % 2 else x * 100]
^
SyntaxError: invalid syntax
Run Code Online (Sandbox Code Playgroud)
有一个像if-else的python表达式:
1 if 0 is 0 else 3
Run Code Online (Sandbox Code Playgroud)
如何在列表理解中使用它?
python list-comprehension ternary-operator conditional-operator
mapunderscore.js中的函数,如果使用javascript对象调用,则返回从对象的值映射的值数组.
_.map({one: 1, two: 2, three: 3}, function(num, key){ return num * 3; });
=> [3, 6, 9]
Run Code Online (Sandbox Code Playgroud)
有没有办法让它保存钥匙?即,我想要一个返回的函数
{one: 3, two: 6, three: 9}
Run Code Online (Sandbox Code Playgroud) 我有一个元素,我想将HTML绑定到它.
<div ng-bind-html="details" upper></div>
这样可行.现在,除此之外,我还有一个绑定到绑定html的指令:
$scope.details = 'Success! <a href="#/details/12" upper>details</a>'
但是upperdiv和锚的指令没有评估.我如何使其工作?
我知道有很多这样的话题.我知道基础知识:.forEach()在原始数组和.map()新数组上运行.
就我而言:
function practice (i){
return i+1;
};
var a = [ -1, 0, 1, 2, 3, 4, 5 ];
var b = [ 0 ];
var c = [ 0 ];
console.log(a);
b = a.forEach(practice);
console.log("=====");
console.log(a);
console.log(b);
c = a.map(practice);
console.log("=====");
console.log(a);
console.log(c);
Run Code Online (Sandbox Code Playgroud)
这是输出:
[ -1, 0, 1, 2, 3, 4, 5 ]
=====
[ -1, 0, 1, 2, 3, 4, 5 ]
undefined
=====
[ -1, 0, 1, 2, 3, 4, 5 ] …Run Code Online (Sandbox Code Playgroud) 我有一个Category Hibernate模型:
@Entity
@Table(name = "category")
public class Category {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
@Column(name = "id")
private long id;
@Column(name = "type")
private String type;
Run Code Online (Sandbox Code Playgroud)
它有一个类型字符串字段.此外,我有一个Java枚举,代表一种类型:
public enum CategoryType {
INCOME, OUTCOME;
}
Run Code Online (Sandbox Code Playgroud)
我想用而不是字符串类型.SQL在varchar参数中接受两个不同的值:CategoryIncome或者CategoryOutcome.我希望Category模型类接受一个枚举变量 - 并在hibernate请求它时以某种方式将其映射到字符串.
可能吗?
我想在子目录/超级目录中执行一个脚本(我需要先在这个子/超级目录中).我无法subprocess进入我的子目录:
tducin@localhost:~/Projekty/tests/ve$ python
Python 2.7.4 (default, Sep 26 2013, 03:20:26)
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> import os
>>> os.getcwd()
'/home/tducin/Projekty/tests/ve'
>>> subprocess.call(['cd ..'])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/subprocess.py", line 524, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib/python2.7/subprocess.py", line 1308, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or …Run Code Online (Sandbox Code Playgroud)