Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Play framework 2.2表单http get_Java_Json_Playframework_Playframework 2.0 - Fatal编程技术网

Java Play framework 2.2表单http get

Java Play framework 2.2表单http get,java,json,playframework,playframework-2.0,Java,Json,Playframework,Playframework 2.0,您好,我在这个框架中绝对是新手。所以我有一个Web服务,其中有api和数据库。所以我应该发送get请求,比如www.mywebserver.com/login?username=guru&password=password,然后它会给出一个类似json的状态:true,这意味着我已经注册了。我已经尝试过了,但没有成功:甚至我都不知道该怎么做 <!DOCTYPE html> <html> <head> <title>LOGI

您好,我在这个框架中绝对是新手。所以我有一个Web服务,其中有api和数据库。所以我应该发送get请求,比如www.mywebserver.com/login?username=guru&password=password,然后它会给出一个类似json的状态:true,这意味着我已经注册了。我已经尝试过了,但没有成功:甚至我都不知道该怎么做

<!DOCTYPE html>

<html>
    <head>
        <title>LOGIN</title>
        <meta charset="utf-8">
        <link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/stylelogin.css")">

        <meta name="viewport" content="width=device-width, initial-scale=1">
        <script type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
            <!--webfonts-->
        <link href='http://fonts.googleapis.com/css?family=Open+Sans:600italic,400,300,600,700' rel='stylesheet' type='text/css'>
            <!--//webfonts-->
    </head>
    <body>
            <!-----start-main---->
        <div class="main">
            <div class="login-form">
                <h1>Member Login</h1>
                <div class="head">
                    <img src="@routes.Assets.at("images/user.png")" alt=""/>

                </div>
                <form>
                    <input type="text" class="text" value="USERNAME" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'USERNAME';}" >
                    <input type="password" value="Password" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Password';}">
                    <div class="submit">
                        <input type="submit" onclick="@controllers.Login.index()" value="LOGIN" >
                    </div>

                </form>
            </div>
                <!--//End-login-form-->
                <!-----start-copyright---->

                <!-----//end-copyright---->
        </div>
            <!-----//end-main---->

    </body>
</html>
字符串名; 串通 如何发送get请求,如www.mywebserver.com/login?username=name&password=pass 其中name和pass来自表单,如果解析json没有错误,则发送请求

package controllers;

import play.data.Form;
import play.mvc.Controller;
import play.mvc.Result;
import views.html.login;

public class Signup extends Controller {

    public static Result login() {
        return ok(
                login.render(Form.form(Login.class))
        );
    }

public static Promise<Result> index() {
final Promise<Result> resultPromise = WS.url(feedUrl).get().flatMap(
        new Function<WS.Response, Promise<Result>>() {
            public Promise<Result> apply(WS.Response response) {
                return WS.url(response.asJson().findPath("status").asText()).get().map(
                        new Function<WS.Response, Result>() {
                            public Result apply(WS.Response response) {
                                return ok("Number of comments: " + response.asJson().findPath("count").asInt());
                            }
                        }
                );
            }
        }
);
return resultPromise;
        public static class Login {


            public String email;
            public String password;


    }
}