Jersey builds a rest service style
Here we will first introduce how to update the list Array Using the rest post method. For details about the concept of rest, refer
Http://blog.csdn.net/lfsfxy9/article/details/9205337
Since the service is provided, there must be a service end and a cient end. Here, some classes encapsulated by the jersey framework are used to demonstrate a rest service-style server and client.
Service end
'@ POST @ Path (/updatePwd) @ Produces ({MediaType. APPLICATION_XML, MediaType. APPLICATION_JSON}) @ Consumes (application/x-www-form-urlencoded) @ SuppressWarnings ({unchecked, rawtypes}) public Response updatePwd (MultivaluedMap
> UserMap) throws ServiceException {// verify if (0. equals (userMap. size () {ServiceRevisionUtils. registerError (STATUS_ICT_ERR_PARAM, pass required parameter is null error, please confirm the parameter is required, not required, parameter length and other information .); } If (StringUtils. isEmpty (userMap. get (token ). toString () {ServiceRevisionUtils. registerError (STATUS_ICT_ERR_PARAM, pass required parameter is null error, please confirm the parameter is required, not required, parameter length and other information .); } HashMap accountPwdMap = new HashMap
(); List userList = new ArrayList
(); UserList = userMap. get (userList); for (int I = 0; I
Client
`public static void main(String[] args) { ClientConfig cc = new DefaultClientConfig(); Client c = Client.create(cc); MultivaluedMap form = new MultivaluedMapImpl(); form.add(token, b310e7cb766146d28caa458fc34ed62a); List userList=new ArrayList
(); userList.add(super,1); userList.add(XPKY01SG03,2); form.put(userList,userList); String baseUrl = http://localhost:8080/baseconnect/rest/fieldServiceRevision/updatePwd; WebResource wr = c.resource(baseUrl); String response = wr.post(String.class, form); System.out.println(result: + response);}`