我试图使用其名称调用对象的函数(我想使用该名称,因为我将从URL检索函数的名称).
我是LUA的初学者,所以我试着了解什么是可能的(或不是!)
在这个例子中,我想从我的主文件中执行对象"controllerUser"的函数"creerCompte()".
我创建了一个主文件:
--We create the controller object
local controller = require("controllers/ControllerUser"):new()
local stringAction = "creerCompte" -- Name of the function to call in the controller Object
--Attempting to call the function stringAction of the object controller
local action = controller:execute(stringAction)
Run Code Online (Sandbox Code Playgroud)
这是控制器对象
ControllerUser = {}
ControllerUser.__index = ControllerUser
function ControllerUser:new()
local o = {}
setmetatable(o, self)
return o
end
function ControllerUser:execute(functionName)
loadstring("self:" .. functionName .. "()") --Doesn't work: nothing happens
getfenv()["self:" .. functionName .. "()"]() --Doesn't work: attempt to …Run Code Online (Sandbox Code Playgroud) 我试图做一个bash脚本,以自动连接到一个ssh服务器.但是,我没有权限安装expect包.所以我想知道是否有办法在被问到时自动输入"是",然后在不使用expect命令的情况下输入密码?
我在xubuntu上工作.
总之,这就是我想要的:
#!/bin/sh
ssh user@localhost << EOT
#enter "yes" here when asked
#enter my password here when asked
ls
EOT
Run Code Online (Sandbox Code Playgroud)
在此先感谢您的帮助.
我开发了一些我想在grails应用程序中使用的Web服务.可以使用Get或POST协议调用这些服务.
我已经看到我需要使用HTTP构建器对象来做到这一点.
这是我的代码:
import groovyx.net.http.HTTPBuilder
import groovyx.net.http.ContentType
import groovyx.net.http.Method
import groovyx.net.http.RESTClient
import groovyx.net.http.HttpResponseDecorator
def http = new HTTPBuilder( 'http://localhost:8086' )
http.request( GET, JSON ) {
uri.path = '/RegistrationService/webresources/users/isRegistered'
uri.query = [ login:'aa', password: 'bb' ]
response.success = { resp, xml ->
def xmlResult = xml
}
}
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是在Netbeans中我每次导入都有一个错误:无法解析类groovyx.net.http.HTTPBuilder无法解析类groovyx.net.http.ContentType ...
但是我尝试运行应用程序,这是我运行代码时的错误:
| Error 2013-02-25 23:33:32,596 [http-bio-8080-exec-3] ERROR errors.GrailsExceptionResolver - MissingPropertyException occurred when processing request: [POST] /WordGame/user/authenticate
No such property: uriPath for class: groovyx.net.http.HTTPBuilder$RequestConfigDelegate. Stacktrace follows:
Message: No such property: uriPath for …Run Code Online (Sandbox Code Playgroud) 我在4.4版本中运行的android模拟器上做了很多测试.在我的应用程序上,我使用SQLiteOpenHelper创建一个带有一个表的sqlite数据库:
package com.findwords.modeles;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteOpenHelper;
import com.findwords.MainActivity;
import com.findwords.controleurs.MenuController;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* Created by louk on 02/01/14.
*/
public class DictionaryDbHelper extends SQLiteOpenHelper{
// declare constants fields
private static final String DB_PATH = "/data/data/com.findwords/databases/";
private static final String DB_NAME = "dictionary_db";
private static final int DB_VERSION = 1;
// declared constant SQL Expression
private static final String DB_CREATE =
"CREATE TABLE dictionary ( " +
"_id integer …Run Code Online (Sandbox Code Playgroud) 我想在我的网站上的iframe中显示一篇Linkedin文章,但是当我使用iframe时,它只显示一个空白页面.Linkedin是否为iframe提供安全保障?我可以做些什么来显示这样的iframe吗?
这是我的代码:
<iframe src="http://www.linkedin.com/today/post/article/20130117141235-20017018-stop-using-these-16-terms-to-describe-yourself?trk=mp-details-rc" frameborder="0" width="100%" height="100%" > Don't work </iframe>
Run Code Online (Sandbox Code Playgroud)
提前致谢.