简体   繁体   English

Jersey HTTP响应200可以,但是返回的内容错误(用户名/密码错误)

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

I was wondering if I wrote the Jersey client side code in the correct way. 我想知道我是否以正确的方式编写了Jersey客户端代码。

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" . 如果任何一个都不正确,则服务器端代码将返回"Username or Password are incorrect"

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. 页面功能运行良好,但是当我使用正确的用户名和密码对使用客户端代码进行测试时,它返回"Username or Password are incorrect" ,响应返回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));
}

I suspect the username and password were not submitted in correct input positions required in HTML file. 我怀疑用户名和密码未在HTML文件中要求的正确输入位置提交。 Below is the block of my HTML file. 以下是我的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.

相关问题 Jersey HTTP响应200可以,但是返回内容错误(检查请求) - Jersey HTTP response 200 OK but returning content wrong (checking request) 泽西Response.ok()不给200 OK - Jersey Response.ok() not giving 200 OK Spring 和 Jackson 在异常后返回状态为 200 OK 但 JSON 不正确的响应 - Spring and Jackson returning a response with status 200 OK but incorrect JSON after an exception 即使输入了错误的密码并且文件未保存在服务器上,我也总是得到服务器响应正常200 - I get always Server Response ok 200 even if I give the wrong password and files are not saved on server OpenRefine 的 API:意外响应:HTTP/1.1 200 ok - OpenRefine's API: Unexpected response: HTTP/1.1 200 ok 即使服务器出错,ResponseBuilder 也会给出 200 OK HTTP 响应 - ResponseBuilder gives 200 OK HTTP response even for server error HTTP 405-200 OK响应上的方法不允许错误 - HTTP 405 - Method Not Allowed error on a 200 OK response rest / javax / jersey / grizzly:是否必须为POST请求返回OK(200)响应代码? - rest/javax/jersey/grizzly: is it mandatory to return OK (200) response code for POST requests? 为什么response.getStatus()返回200 OK,即使实际响应不是 - Why is response.getStatus() returning 200 OK even when the actual response is not 方法之间最好返回HTTP OK响应 - Which is best between approach by returning HTTP OK response
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM