jax-rs retrieve form parameters

前端 未结 1 1898
萌比男神i
萌比男神i 2021-01-03 22:17

I\'m trying to retrieve some parameters that are passed to jax-rs from a posted form with the HttpServletRequest. However, my request object is always returning null values

1条回答
  •  忘掉有多难
    2021-01-03 22:41

    @POST
    @Path("/authenticate")
    @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
    public void authenticate(@FormParam("email") String email, @FormParam("password") String password) throws Exception {
    
        if (loginService.authenticate(email, password)) {
            response.sendRedirect("/app");
        } else {
            request.setAttribute("authenticationError", "Invalid email/password.");
    
        }
    }
    

    0 讨论(0)
提交回复
热议问题