Newbie: in a Jersey structure, how to get the data of an HTML form object in my case?

When the client side submits an HTML form , it sends the form object to the server, for example:

params={username: USER_INPUT_USERNAME,
       passworkd: USER_INPUT_PASSWORD}

Then the ajax client will send the params object to my jersey server .

On the server side, how can I get and parse the data of this HTML form object params:

@GET
@Produces({MediaType.APPLICATION_JSON})
public FormResult getFormResult(@QueryParam("params") Object params) {
                 //How can I define the type of the "params" I received?
                 //Do I need to create a Java Bean which represent the HTML form, 
                 //and use the bean as the type of paprams? or any other way?
}

(In the above code, the return type FormResultis a POJO bean that describe the result for the response to the client)

When I get the data of an paramsHTML form form object , how can I determine the type params? (I defined it with type " Object" above , which is not true).

POJO bean HTML bean params? ?

( POJO bean HTML-, HTML- , params , params, )

- ?

+3
1

@QueryParam queryString, GET :

@GET
getFormResult(@QueryParam("name") String name, @QueryParam("age") int age, ... )

params (http://your.rest.service?params=somethingHere), - , , String static valueOf(String), .

@GET
getFormResult(@QueryParam("params") FormData formData);

FormData :

public class FormData {
    public FormData(String s) {
        // populate fields based on the content of s
    }

    // getters / setters / whatever ...
}

EDIT: , : , -, , , , . , a @QueryParam("chk") String[] checkedValues "" (, "" ).

+3

All Articles