我有SpringMVC项目,Freemarker作为视图解析器.在一些模板中,我必须生成包括主机名在内的链接,但我无法得到它.在JSP中,我可能会这样做:
`<% String hostName=request.getServerName();%>`
Run Code Online (Sandbox Code Playgroud)
我试图使用" requestContextAttribute",但requestContext.getContextPath()返回没有主机名的路径.我在哪里可以单独获得完整路径或主机名?
我正在使用 webpack 构建我的 angular.js 应用程序。举一个简单的例子:
应用程序.js
var angular = require('exports?window.angular!angular'),
angularMoment = require('angular-moment');
angular.module('myApp', [angularMoment]);
Run Code Online (Sandbox Code Playgroud)
角矩.js
define(['angular', 'moment'], function(angular, moment) {
// some library code
});
Run Code Online (Sandbox Code Playgroud)
这里有两种导入角度的方式,使用加载器和仅通过名称。它导致角度将被注入到页面两次,我在控制台中看到以下警告:
WARNING: Tried to load angular more than once.
Run Code Online (Sandbox Code Playgroud)
有没有办法让 webpack 将 Angular 的导入视为同一个模块?
我的webpack.conf.js
module.exports = {
entry: {
'app': './src/app/app.js'
},
plugins: [
new webpack.ResolverPlugin(
new webpack.ResolverPlugin.DirectoryDescriptionFilePlugin("bower.json", ["main"])
),
new AngularPlugin()
]
};
Run Code Online (Sandbox Code Playgroud) 我现在正在使用Redux一段时间,我很喜欢它:)
在处理嵌套数组时,我对如何组合reducers有点困惑.我有一个用户对象,它有一个评论列表.每篇评论都可以包含review_comments列表.
{
user: {
id: 1,
reviews: [{
id: 1,
comments: [{
id: 1,
message: "Test"
}, {
id: 2,
message: "123"
}, {
id: 3,
message: "456"
}]}, {
id: 2,
comments: [{
id: 5,
message: "qwerty"
}, {
id: 6,
message: "1542354"
}, {
id: 7,
message: "45we 6"
}]
}]
}}
Run Code Online (Sandbox Code Playgroud)
现在,所有这些都在同一个UserReducer中.每次状态发生变化时,我都会在评论/评论列表中进行映射.随着数据量的增长,reducers变得更加嵌套,管理起来也很复杂.
有没有办法把它组成3个减速器:UserReducer,ReviewReducer和CommentReducer?
谢谢您的帮助.
我正在尝试从当前使用的iTerm切换到Hyperterm。但是我在终端中有一个自定义的背景图片,我想继续在新终端中使用它。
backgroundColor到目前为止,我仅在选项中找到,但与背景图片无关。
我有一个包含很多项目的列表.我想先显示10,然后点击相应按钮后显示所有内容.我这样做:http://plnkr.co/edit/rq8SsE ?p = preview如何用filter而不是ng-show做同样的事情.在更复杂的情况下,这种方法更有效.
我有一个简单的文件观察器构建 chokidar
require('chokidar').watch('./target.txt', {}).on('all', function(event, path) {
console.log(event, path);
}).on('ready', function() {
console.log('ready');
});
Run Code Online (Sandbox Code Playgroud)
change每次我重新保存文件时,即使没有更改,它也会引起事件。只有在实际内容已更改的情况下,才有办法使此火灾事件发生吗?
所以,我有一个支持promises的nodejs:
$ node -v
v0.11.11
Run Code Online (Sandbox Code Playgroud)
但是当我尝试使用Promises时,我有一个错误:
$ node --harmony test.js
require, module, __filename, __dirname) { var promise = new Promise(fu
^
ReferenceError: Promise is not defined
at Object.<anonymous> (/home/just-boris/coding/test.js:1:89)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:349:32)
at Function.Module._load (module.js:305:12)
at Function.Module.runMain (module.js:490:10)
at startup (node.js:123:16)
at node.js:1128:3
Run Code Online (Sandbox Code Playgroud)
我的要点中的源代码
我做错了什么?此外,我尝试运行生成器示例并且它正在工作,因此这意味着es6功能已启用,但承诺除外
我使用Normalizr从不同的API端点获得相同的响应形状.
const post = new Schema('posts');
const posts = arrayOf('post');
const listResponse = [
{id: 1, text: 'post one'},
{id: 2, text: 'post two'},
];
normalize(listResponse, posts);
/*
{
entities: {
posts: {
1: {id: 1, text: 'post one'},
2: {id: 2, text: 'post two'}
}
},
result: [1, 2]
}
*/
const singleResponse = {id: 1, text: 'post one'};
normalize(singleResponse, post);
/*
{
entities: {
posts: {
1: {id: 1, text: 'post one'}
}
},
result: 1
}
*/ …Run Code Online (Sandbox Code Playgroud)