Team work for the fourth time: Community application App

Source: Internet
Author: User

Profile:

Based on the last software design in a concise interface, easy to use the original intention, the implementation of the function, code location: Https://github.com/LinZezhong/testDemo

The first part: the use of software

Registered:

Login:

Main interface (all societies shown):

Click on the community to jump to the Community application page:

Click Apply to submit your application

If you have applied for this department, you will be prompted to "have applied"

Click "Personal" on the main screen to view personal information changes

Click "Audit" on the main screen to show the Community department that you have permission to audit

Click on the appropriate department to have the appropriate department to process the application:

Click

Click Submit to complete the audit of the application

At this point, 201521121076 users click on "My Application" to view their application

Click to show your application results and notifications

Part Two: Implementation of code (using HTTP data transfer)

The client is using eclipse editing

The structure is as follows:

The server was built by me on the cloud server, using Myeclipse+tomcat+mysql

MyEclipse:

Idea: Depending on the client's different functions required to connect to the server side of the different servlets, there is a servlet call the corresponding MySQL operation method to obtain the corresponding data, the distribution of JSON data transfer to the client.

Client:

Use URLConnection to send a request to the server side in post mode.

Request Method:

public class Getpostutil {public static final String urlbase= "http://111.230.230.93:8080/LinkMySQL/servlet/";p ublic static string Sendpost (string url,string params) {printwriter out = null; BufferedReader in = null; String json=null;try {URL realurl = new URL (URL); URLConnection conn = Realurl.openconnection ();//Set Generic Request Properties Conn.setrequestproperty ("Accept", "*/*"); Conn.setrequestproperty ("Connecttion", "keep-alive"); Conn.setrequestproperty ("User-agent", "Mozilla/4.0" ( Compatible MSIE 6.0; Windows NT 5.1; SV1) "///Send the POST request must set the two lines conn.setdooutput (true);//get the output stream of the URLConnection object out = new PrintWriter (Conn.getoutputstream ());//Send request parameter out.print (params);//flush buffer Stream Buffer Out.flush ();// Defines the Bufferdreader input stream to read the response of the URL in = new BufferedReader (New InputStreamReader (Conn.getinputstream ())); Conn.getinputstream (); json = Netutil.readstring (IS); return JSON;} catch (Exception e) {System.out.println ("send POST request exception! "+e"); E.printstacktrace ();} Finally{try{if (out!=null) {out.close ();} if (In! = Null) {in.close ();}} catch (IOException e) {e.printstacktrace ();}} return JSON;}}

The data returned by the server is converted to a JSON string method:

public class Netutil {public static byte[] Readbytes (InputStream is) {try {    byte[] buffer = new byte[1024];    int len =-1;    Bytearrayoutputstream BAOs = new Bytearrayoutputstream ();    while (len = is.read (buffer))! =-1) {        baos.write (buffer, 0, Len);    }    Baos.close ();    return Baos.tobytearray ();    } catch (Exception e) {        e.printstacktrace ();    }    return null;} public static string ReadString (InputStream was) {return new string (Readbytes (IS));}}

  

  

Team work for the fourth time: Community application App

Related Article

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.