The formatting of incoming parameters of Web Access layer and the parameter formatting of the Web return value outgoing data, all must be unified

Source: Internet
Author: User

The formatting of the incoming parameters of the 1.web access layer and the parameter formatting of the outgoing data of the Web return value should be unified.

Like in Acspace,

The incoming layer parameter @requestbody the JavaBean object. Unified conversion to JavaBean incoming parameters.

Returns a value that returns the Resultobject object uniformly, Resultobject implements serialization. And the Resultobject defines which properties are transferred back,

3.ResultObject, defined public outgoing parameter properties

 Public classResultobject implements Serializable {/**     *      */    Private StaticFinalLongSerialversionuid =-2523760680706423997L; PrivateString Res_info =""; PrivateObject data =""; Private intresult = $; //TODO Paging Object     PublicResultobject (String res_info) { This. Res_info =Res_info; }     Publicresultobject (Object data) { This. data =data; }     PublicResultobject (ResultCode resultcode) { This. Res_info =Resultcode.getname ();  This. result =Resultcode.getindex (); } @SuppressWarnings ("unchecked")     Public<t extends Resultobject>T configerrmsg (ResultCode err) { This. Setresult (Err.getindex ());  This. Setres_info (Err.getname ()); returnT This; }     PublicResultobject () {} PublicString Getres_info () {returnRes_info; }     Public voidSetres_info (String res_info) { This. Res_info =Res_info; }     PublicObject GetData () {returndata; }     Public voidsetData (Object data) { This. data =data; }     Public intGetResult () {returnresult; }     Public voidSetresult (intresult) {         This. result =result; }}

3. Returns a Resultobject object that defines multiple constructors.

Used to pass in different types and return them. Yes

Resultobject (String res_info)
Resultobject (ResultCode ResultCode)
Resultobject (Object data)
    Private StaticFinalLongSerialversionuid =-2523760680706423997L; PrivateString Res_info =""; PrivateObject data =""; Private intresult = $; //TODO Paging Object     PublicResultobject (String res_info) { This. Res_info =Res_info; }     Publicresultobject (Object data) { This. data =data; }     PublicResultobject (ResultCode resultcode) { This. Res_info =Resultcode.getname ();  This. result =Resultcode.getindex (); } @SuppressWarnings ("unchecked")     Public<t extends Resultobject>T configerrmsg (ResultCode err) { This. Setresult (Err.getindex ());  This. Setres_info (Err.getname ()); returnT This; }

The formatting of incoming parameters of Web Access layer and the parameter formatting of the Web return value outgoing data, all must be unified

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.