<script type="text/javascript">
(function(){ var p = { url:location.href, to:'qqmail', desc:'', /*默认分享理由(可选)*/ summary:'',/*摘要(可选)*/ title:'',/*分享标题(可选)*/ site:'',/*分享来源 如:腾讯网(可选)*/ pics:'' /*分享图片的路径(可选)*/ }; var s = []; for(var i in p){ s.push(i + '=' + encodeURIComponent(p[i]||'')); } document.write(["<a target='_blank' ", 'href="http://mail.qq.com/cgi-bin/qm_share?', s.join("&"), '"', ' style="cursor:pointer;text-decoration:none;outline:none"><img src="http://rescdn.qqmail.com/zh_CN/htmledition/images/function/qm_open/ico_share_02.png"/></a>'].join("")); })(); </script>
<a target="_blank" href="http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=HXB8bmxoeHFyXXtyZXB8dHEzfnJw" style="text-decoration:none;"><img src="http://rescdn.qqmail.com/zh_CN/htmledition/images/function/qm_open/ico_mailme_12.png"/></a>
json-lib的解析
public ResultData save1(HttpServletRequest request) { // 得到字符串形式的数据 String orderStr = JsonUtils.formatStr(request.getParameter("order")); String salesLegInfoesStr = request.getParameter("salesLegInfoes"); String postInfoStr = request.getParameter("postInfo"); String travellersStr = request.getParameter("travellers"); Mapjackson的解析inMap = new HashMap (); SalesOrder order = null; // 格式化json的时间,否则时间无法对应的保存 JSONUtils.getMorpherRegistry().registerMorpher(new DateMorpher(new String[] { "yyyy-MM-dd" })); order = (SalesOrder) JSONObject.toBean( JSONObject.fromObject(orderStr), SalesOrder.class); /*List salesLegInfos = (List ) JSONArray .toCollection(JSONArray.fromObject(salesLegInfoesStr), SalesLegInfo.class);*/ /* List salesLegInfos = new ArrayList (); JSONArray salesLegInfoesArr = JSONArray.fromObject(salesLegInfoesStr); for(int i= 0;i salesFreightRates = (List )JSONArray .toCollection(JSONArray.fromObject(salesLegInfoeJson.get("salesFreightRates")), SalesFreightRate.class); salesLegInfo.setSalesFreightRates(salesFreightRates); salesLegInfos.add(salesLegInfo); } SalesPostInfo postInfo = (SalesPostInfo) JSONObject.toBean( JSONObject.fromObject(postInfoStr), SalesPostInfo.class); JSONArray travellersJsonArr = JSONArray.fromObject(travellersStr);// 旅客信息 // 票的信息 List travellers = new ArrayList (); for (int i = 0; i < travellersJsonArr.size(); i++) { JSONObject travellerJson = (JSONObject)travellersJsonArr.get(i); SalesTraveller salesTraveller = (SalesTraveller) JSONObject.toBean( JSONObject.fromObject(JsonUtils.formatStr((JSONObject.fromObject(travellersJsonArr.get(i))).discard("tickets").toString())), SalesTraveller.class); JSONArray ticketsJsonArr = JSONArray.fromObject(travellerJson.get("tickets")); List tickets = new ArrayList (); for (int j = 0; j < ticketsJsonArr.size(); j++) { JSONObject ticketJson = JSONObject.fromObject(ticketsJsonArr .get(j)); if(!"null".equals(ticketJson.toString())&&ticketJson!=null&&!"".equals(ticketJson)){ SalesTicket ticket = (SalesTicket) JSONObject.toBean(JSONObject .fromObject(JsonUtils.formatStr(ticketJson.discard("ticketUnites").toString())), SalesTicket.class); List ticketUnite = (List ) JSONArray .toCollection(JSONArray.fromObject(((JSONObject)ticketsJsonArr .get(j)).get("ticketUnites")), SalesTicketUnite.class); ticket.setTicketUnites(ticketUnite); tickets.add(ticket); } } salesTraveller.setSalesTickets(tickets); travellers.add(salesTraveller); } order.setSalesLegInfos(salesLegInfos); order.setSalesPostInfo(postInfo); order.setSalesTravellers(travellers); salesOrderService.save(order); inMap.put("order", order); return new ResultData(inMap); }
public ResultData save(HttpServletRequest request) { // 得到字符串形式的数据 MaprMap = new HashMap (); String orderStr = JsonUtils.formatStr(request.getParameter("order")); String salesLegInfoesStr = request.getParameter("salesLegInfoes"); String postInfoStr = request.getParameter("postInfo"); String travellersStr = request.getParameter("travellers"); ObjectMapper mapper= new ObjectMapper(); mapper.getSerializationConfig().setDateFormat(new SimpleDateFormat("yyyy-MM-dd")); SalesOrder order = null; List salesLegInfoList = new ArrayList (); try { order = mapper.readValue(orderStr, SalesOrder.class); SalesPostInfo salesPostInfo = mapper.readValue(postInfoStr, SalesPostInfo.class); List > salesLegInfoMapList = mapper.readValue(salesLegInfoesStr, List.class); for(LinkedHashMap map: salesLegInfoMapList){ List salesFreightRates = mapper.readValue(map.get("salesFreightRates").toString(), new TypeReference
>() {}); map.remove("salesFreightRates"); SalesLegInfo salesLegInfo = mapper.convertValue(map, SalesLegInfo.class); salesLegInfo.setSalesFreightRates(salesFreightRates); salesLegInfoList.add(salesLegInfo); } List > travellersMapList = mapper.readValue(travellersStr, List.class); List travellers = new ArrayList (); for (LinkedHashMap map: travellersMapList) { List > ticketsMapList = mapper.readValue(map.get("tickets").toString(), List.class); List tickets = new ArrayList (); for (LinkedHashMap inMap: ticketsMapList) { List ticketUnites = mapper.readValue(inMap.get("ticketUnites").toString(), new TypeReference
>() {}); inMap.remove("ticketUnites"); SalesTicket ticket = mapper.convertValue(inMap, SalesTicket.class); ticket.setTicketUnites(ticketUnites); tickets.add(ticket); } map.remove("tickets"); SalesTraveller salesTraveller = mapper.convertValue(map, SalesTraveller.class); salesTraveller.setSalesTickets(tickets); travellers.add(salesTraveller); } order.setSalesLegInfos(salesLegInfoList); order.setSalesPostInfo(salesPostInfo); order.setSalesTravellers(travellers); salesOrderService.save(order); rMap.put("order", order); } catch (JsonParseException e) { e.printStackTrace(); } catch (JsonMappingException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return new ResultData(rMap); }