Jersey HTTP响应200 OK但返回内容错误(用户名/密码不正确) [英] Jersey HTTP response 200 OK but returning content wrong (username/password incorrect)

查看:132
本文介绍了Jersey HTTP响应200 OK但返回内容错误(用户名/密码不正确)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道我是否以正确的方式编写了Jersey客户端代码。

I was wondering if I wrote the Jersey client side code in the correct way.

登录页面应该在正确的用户名后重定向到主页面密码输入,服务器端返回一个空字符串()。如果其中一个不正确,服务器端代码返回用户名或密码不正确

The log-in page is supposed to redirect to main page after correct username and password input, with server side returning an empty string (""). If either is incorrect, server side code returns "Username or Password are incorrect".

页面功能运行良好但是当我使用正确的用户名和密码对我的客户端代码进行测试时,它返回用户名或密码不正确,响应返回200OK。下面是我的客户端代码。

The page functionality worked well but when I was testing using my client side code using a correct pair of username and password, it returns "Username or Password are incorrect", with response returning 200OK. Below is my client side code.

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文件块。

I suspect the username and password were not submitted in correct input positions required in HTML file. Below is the block of my HTML file.

 <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>


推荐答案

使用登录而不是用户名用于发布数据。

Use login instead of username for the post data.

这篇关于Jersey HTTP响应200 OK但返回内容错误(用户名/密码不正确)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆