Redirecting to a page using restful methods?

前端 未结 5 737
广开言路
广开言路 2021-02-14 11:36

I\'ve created a page which asks user to fill some form fields and when he submits, the form is sent to a Restful method which you can see below:

@POST
@Path(         


        
5条回答
  •  情深已故
    2021-02-14 12:18

    See below the usage of redirecting in web services:

    public class LoginWebService {
    
        @POST
        @Path("/check")
        public Response checkDetails(@FormParam("name") String name,@FormParam("pass") String pass ) throws URISyntaxException  {
    
            URI uri = new URI("/login/success");
            URI uri2= new URI("http://localhost:9090/NewWebServiceproject/new/login/failure");
    
            if(name.equals("admin") && pass.equals("pass"))
        //@Path("http://localhost:8010/NewWebServiceproject/new/login/success");
                {
                return Response.temporaryRedirect(uri).build();
                //Response.seeOther(uri);
                //return Response.status(200).entity("user successfully login").build();
                }
            else
            {
                return Response.temporaryRedirect(uri2).build();
                //Response.seeOther(uri2);
                //return Response.status(200).entity("user logon failed").build();
                }
        }
        @POST
        @Path("/success")
        public Response successpage()
        {
        return Response.status(200).entity("user successfully login").build();
        }
        @POST
        @Path("/failure")
        public Response failurepage()
        {
        return Response.status(200).entity("user logon failed").build();
        }
    }
    

提交回复
热议问题