有谁知道是否有可能从速度不同的路径获取模板?初始化后,Velocity拒绝更改"file.resource.loader.path".
这是我的代码:
public Generator(){
Properties p = new Properties();
p.setProperty("resource.loader", "file");
p.setProperty("file.resource.loader.class", "org.apache.velocity.runtime.resource.loader.FileResourceLoader");
p.setProperty("file.resource.loader.path", "");
Velocity.init(p);
}
Run Code Online (Sandbox Code Playgroud)
模板可以位于不同的位置(用户可以选择带有文件对话框的模板).所以我在从速度中取出模板时有这个代码
private Template fetch (String templatePath) {
out_println("Initializing Velocity core...");
int end = templatePath.lastIndexOf(File.separator);
Properties p = new Properties();
p.setProperty("file.resource.loader.path", templatePath.substring(0, end));
Velocity.init(p);
return Velocity.getTemplate(templatePath.substring(end+1));
}
Run Code Online (Sandbox Code Playgroud)
这不起作用.似乎一旦Velocity初始化,它就不能用不同的属性重置.有关如何解决这个问题的任何建议?
可能的计划流程:
我刚刚开始使用mongo db并试图做一些简单的事情.我用包含"item"属性的数据集填充了我的数据库.我想尝试计算每个项目在集合中的时间
文件的例子:
{ "_id" : ObjectId("50dadc38bbd7591082d920f0"), "item" : "Pons", "lines" : 37 }
Run Code Online (Sandbox Code Playgroud)
所以我设计了这两个函数来做MapReduce(使用pymongo在python中编写)
all_map = Code("function () {"
" emit(this.item, 1);"
"}")
all_reduce = Code("function (key, values) {"
" var sum = 0;"
" values.forEach(function(value){"
" sum += value;"
" });"
" return sum;"
"}")
Run Code Online (Sandbox Code Playgroud)
这就像一个魅力,所以我开始填充这个系列.在周围30.000文件,在映射缩减已经持续一秒钟以上......因为NoSQL的被吹嘘的速度,我想我一定是在做什么错了!
Stack Overflow的一个问题让我查看了mongodb的聚合功能.所以我尝试使用group + sum + sort thingies.得出这个:
db.wikipedia.aggregate(
{ $group: { _id: "$item", count: { $sum: 1 } } },
{ $sort: {count: 1} }
)
Run Code Online (Sandbox Code Playgroud)
这段代码工作正常,并给我与mapreduce集相同的结果,但它同样慢.难道我做错了什么?我真的需要使用像hadoop …
我正在为一个自制API的消费者工作,并且在设置Authorization标头时遇到了严重的困难.我正在使用JQuery来处理Ajax请求,但'beforeSend'根本不起作用(使用fiddler来检查请求)
这是我的beforeSend代码:
$.ajax({
type: "GET",
url: url+"/Projects",
contentType: "application/json; charset=utf-8",
beforeSend: function (req) {
req.setRequestHeader("Authorization", AuthBuilder(username, password));
},
success: function (result) {
alert("success");
},
error: function (xhr, ajaxOptions, thrownError) {
alert("fail");
}
});
Run Code Online (Sandbox Code Playgroud)
那么如果失败你会怎么做?回到发送ajax请求的旧方式......这也不起作用......
这是我的常规代码:
function GET(address, callback, error) {
Request = getXMLHttpObject();
Request.open("GET", url + address, true);
var base64 = Base64.encode(username + ":" + password);
alert(base64);
Request.setRequestHeader("Authorization", "Basic " + base64);
Request.send();
Request.onreadystatechange = function () {
//alert(Request.readyState+" code "+Request.status);
if (Request.readyState == …Run Code Online (Sandbox Code Playgroud) 我创建了一个启用 p2 的 RCP 应用程序。添加了 ui,也可以添加更新站点。
但是添加新软件(已安装),会发生这种情况:
Your original request has been modified.
"Help" is already installed, so an update will be performed instead.
Cannot complete the install because of a conflicting dependency.
Software being installed: Help 1.0.0.201210110844 (smartapps.smartsignature.features.help.feature.group 1.0.0.201210110844)
Software currently installed: SmartSignature 1.0.0.201210110831 (smartapps.smartsignature.application.product 1.0.0.201210110831)
Only one of the following can be installed at once:
Help 1.0.0.201210110844 (smartapps.smartsignature.features.help.feature.jar 1.0.0.201210110844)
Help 1.0.0.201210110831 (smartapps.smartsignature.features.help.feature.jar 1.0.0.201210110831)
Cannot satisfy dependency:
From: SmartSignature 1.0.0.201210110831 (smartapps.smartsignature.application.product 1.0.0.201210110831)
To: smartapps.smartsignature.features.help.feature.group [1.0.0.201210110831]
Cannot satisfy dependency:
From: …Run Code Online (Sandbox Code Playgroud)