簡體   English   中英

Jersey HTTP響應200可以,但是返回的內容錯誤(用戶名/密碼錯誤)

[英]Jersey HTTP response 200 OK but returning content wrong (username/password incorrect)

我想知道我是否以正確的方式編寫了Jersey客戶端代碼。

輸入正確的用戶名和密碼后,登錄頁面應該重定向到主頁,服務器端返回一個空字符串( "" )。 如果任何一個都不正確,則服務器端代碼將返回"Username or Password are incorrect"

頁面功能運行良好,但是當我使用正確的用戶名和密碼對使用客戶端代碼進行測試時,它返回"Username or Password are incorrect" ,響應返回200OK。 下面是我的客戶端代碼。

public static void main(String[] args){
    ClientConfig config = new ClientConfig();
    Client client = ClientBuilder.newClient(config);
    WebTarget target = client.target("http://localhost:8080
                               /qa-automation-console").path("authenticate");
    Form form = new Form();
    form.param("username", "username");
    form.param("password", "password");
    Response response = target.request().post(Entity.form(form));
     //The response was 200OK.
    System.out.println(response.readEntity(String.class));
}

我懷疑用戶名和密碼未在HTML文件中要求的正確輸入位置提交。 以下是我的HTML文件的代碼段。

 <form name="j_security_form" method="post" action="j_security_check">

  <td colspan="3" class="body"><strong>Please contact the service desk for additional 
                                              information.</strong></td>

  <td colspan="3" align="left"><p class="errorTitle"></p></td>

<span>

    <td colspan="3" align="left"><p class="subTitle1">Please log in:</p></td>

    <input class="input-small input-block" ng-model="username" placeholder="Username" 
        id="top_login" name="login" value="" autocomplete="on" type="text"></input>

    <td colspan="3" align="left"><p class="space"></p></td>

    <input class="input-small input-block" ng-model="password" placeholder="Password" 
     id="top_password" name="password" value="" autocomplete="on" type="password"></input>

  </span>
  <li style="display: none;" id="message" class="login-fail hidden">Wrong username 
                                                            or password</li>
</form>

使用login username而不是username作為帖子數據。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM