How to write the code before and after the Ajax way to interact with each other

Source: Internet
Author: User

1  Packagecom.zq.www.mis.action;2 3 Importjava.util.List;4 5 ImportOrg.apache.struts2.convention.annotation.Result;6 ImportOrg.apache.struts2.convention.annotation.Results;7 Importorg.springframework.beans.factory.annotation.Autowired;8 9 Importcom.zq.www.common.BaseAction;Ten ImportCom.zq.www.mis.dao.TorderManagerDAO; One /** A  *  -  * @authorZZW Order Review -  * the  */ -@SuppressWarnings ("Serial") - @Results ({ -@Result (name = "Show", location = "/backsadmin/order_approve/list.jsp"), +@Result (name = "Shenhes", location = "/backsadmin/order_approve/list.jsp") -     + }) A  Public classOrder1actionextendsbaseaction{ at @Autowired -     PrivateTordermanagerdao DAO; -List<string[]>orderlist; -     PrivateInteger ID; -     PrivateString Ajaxtext; -      in      -      to      +      -      the      *      $     Panax Notoginseng      -      the     //Front desk showing all information to be audited +      PublicString Show1 ()throwsexception{ Aorderlist=Dao.select (); the      This. Ajaxsendjson (OrderList,true); I encapsulated the Code +     return NULL; -     } $     //This function modifies the payment status of the corresponding parameter to "refunded" $      PublicString Shenhe ()throwsexception{ -System.out.println ("id=" +ID);  - dao.updatestatus (ID); the      This. ajaxsendsuccess (); -     return NULL;Wuyi     } the     //Batch Modification -      PublicString shenhes ()throwsException Wu     { -System.out.println ("ajaxtext=" +ajaxtext);  AboutString[] A=ajaxtext.split (","); $      for(inti=1;i<a.length;i++) -     { -SYSTEM.OUT.PRINTLN ("disassembled value is;" +a[i]); - Dao.updatestatus (Integer.parseint (a[i)); A          +     }     the     return"Shenhes"; -     } $      the      the      the      the      -      in      the      the      About    the     the  the      +      PublicList<string[]>getorderlist () { -         returnorderlist; the     }Bayi      Public voidSetorderlist (list<string[]>orderlist) { the          This. orderlist =orderlist; the     } -      PublicInteger getId () { -         returnID; the     } the      Public voidsetId (Integer id) { the          This. ID =ID; the     } -      PublicString Getajaxtext () { the         returnAjaxtext; the     } the      Public voidSetajaxtext (String ajaxtext) {94          This. Ajaxtext =Ajaxtext; the     } the      the}

The code I encapsulated is as follows

1  PackageCom.zq.www.common;2 3 ImportJavax.servlet.ServletContext;4 Importjavax.servlet.http.HttpServletRequest;5 ImportJavax.servlet.http.HttpServletResponse;6 Importjavax.servlet.http.HttpSession;7 8 ImportOrg.apache.struts2.ServletActionContext;9 Ten ImportCom.alibaba.fastjson.JSON; One Importcom.alibaba.fastjson.serializer.SerializerFeature; A ImportCom.opensymphony.xwork2.ActionSupport; -  -  the //extracted public Action -  Public classBaseactionextendsactionsupport{ -      -      +     //simplified functions for obtaining request/response/session// -          +         /** A * Simplified method of obtaining HttpRequest. at          */ -          Public Statichttpservletrequest getrequest () { -             returnservletactioncontext.getrequest (); -         } -  -         /** in * Simplified method of obtaining HttpResponse. -          */ to          Public StaticHttpServletResponse GetResponse () { +             returnservletactioncontext.getresponse (); -         } the          *         /** $ * Simplified method of obtaining httpsession.Panax Notoginseng          */ -          Public StaticHttpSession getsession () { the             returnservletactioncontext.getrequest (). getsession (); +         } A          the         /** + * Simplified method of obtaining application. -          */ $          Public StaticServletContext getapplication () { $             returnServletactioncontext.getservletcontext (); -         } -          the          -         /**Wuyi * Send normal JSON the          */ -          Public Static voidAjaxsendjson (Object obj)throwsexception{ WuAjaxsendjson (obj,false); -         } About          $         /** - * Send normal JSON with date -          */ -          Public Static voidAjaxsendjson (Object obj,BooleanIsDate)throwsexception{ AString result= ""; +             if(isDate) theresult=json.tojsonstring (Obj,serializerfeature.writedateusedateformat); -             Else $result=json.tojsonstring (obj); the getResponse (). Getwriter (). write (result); the         } the          the         /* - * Send Success in          *  the          */ the          Public Static voidAjaxsendsuccess ()throwsexception{ AboutGetResponse (). Getwriter (). Write (Json.tojsonstring ("Success")); the         } the          the          +          -  the}

How to write the code before and after the Ajax way to interact with each other

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.