Play framework 2.2 Form http get

2019-08-07 15:08发布

问题:

Hello I am absolutely newbie in this framework.So I have webservice where I have api and database.So I should send get request like www.mywebserver.com/login?username=guru&password=password then it will give anwser in json like status:true it means I have registered.I have tried but unsuccessfully:Even I dont know steps to do it

<!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 /login controllers.Signup.login()

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;


    }
}

String name; String pass How to sent get request like www.mywebserver.com/login?username=name&password=pass Where name and pass comes from form and send request if no error parse json