[英]Playframework Result how check is working
Hello I have got small problem I'm learning play 2.2.1 framework and I was making controllers like 您好,我在学习play 2.2.1框架时遇到了一个小问题,我在制作控制器,例如
public static Result Name(){
List<Account> names = Account.find.all();
List name = new ArrayList();
for(Account a: names)
{
name.add(a.getName());
}
return ok(Json.toJson(name));
}
And in routes I added line 在路线中,我添加了行
GET /api/name controllers.AccController.Name()
And this function gives me all names from database now I wanted to make function where i can choose what column from database name/surname/country I want to get I made something like this: 这个函数为我提供了数据库中的所有名称,现在我想创建一个函数,在该函数中我可以从数据库名称/姓氏/国家/地区中选择要显示的列,然后进行如下操作:
public static Result typewhat(String what) {
String[] type = what.split(" ");
then I made if type[1] == name and same like upper but I dont know how to test now thats working or not in Routes I add line: 然后我做了,如果type [1] == name并且像upper一样,但是我不知道现在如何测试那条路线是否有效,我添加了以下代码:
PUT /api/findwhat controllers.AccController.typewhat(what: String)
Im using Open HttpRequester and for localhost:9000/api/name it is working 我正在使用Open HttpRequester并为localhost:9000 / api / name运行
but I totally dont know how to make it for this functiong typewhat 但我完全不知道如何使这种功能类型
I will be very thankful for every help. 我将非常感谢您的每一次帮助。
PUT /api/findwhat controllers.AccController.typewhat(what: String)
for above path try 对于上述路径尝试
localhost:9000/api/name?what=this is that
dont know java well but in scala it works fine 不太了解Java,但在Scala中工作正常
def typewhat(what:String) = Action { implicit request =>
println("gs",what)
val strAr = what.split(" ")
println(strAr)
Ok(strAr(0))
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.