The design of Java Web back-end registration interface from zero development of app __java

Source: Internet
Author: User

Starting today, I'm going to take you from zero to develop a sports Android APP, including back-end construction, where we use the Java Web servlet, the personal server uses Tomcat, and the database uses MySQL.

Because we are the front and back of the design of their own, so in the design interface, the front-end and back end no longer love to kill, everything is our own to decide.


First, the logical design:

Today we design the interface to register, design the interface, of course, we must first consider the need to implement the kind of function. Client registration, you need to get the user name and password and nickname by post Way to the server, of course, later we need to give all the content of the request encryption process, can not let the middleman directly get the plaintext password.

Server-side in obtaining username and password as well as nicknames, you need to make the following judgments, first to determine whether the user name and nickname are duplicates in the database, if there is no duplication, then the write operation. If there are duplicates, then the corresponding error code is returned.


Second, the database design:

After the logical design is finished, we need to design the user table Tal_user, through the above requirement, we know at least the following four fields, one for the user's ID, two for the user's username, three for the user's password, four for the user's nickname. However, we also need a field, that is the user's token, the user token the role is very large, it can accomplish a lot of password can not complete the task. Here is a brief introduction to the use of token:

Token can be viewed as a server-side generation of a user's temporary ID, which must be unique in the user table to uniquely identify a user. In this way, the user login, the server side generates a token, and then return to the client, the client can use this token each time to obtain data, so that each fetch data without carrying password to verify, to ensure the security of users. Second, because each time the user login is a freshman into a token replace the old token, so that users who originally logged on to other devices will be offline, so that users can be limited to login on one device (now most apps are designed this way).

Therefore, a token field is also required in the user table.

The following SQL statements are created for the user table:

CREATE TABLE Tal_user (
ID INT (one) unsigned NOT NULL auto_increment,
Name varchar NOT NULL unique,
Password varchar (m) NOT NULL,
Nickname varchar (m) NOT NULL,
Token varchar (50),
Primary KEY (ID)
) Engine=innodb DEFAULT Charset=utf8


Third, the interface specification:

After the database is designed, the server side needs to design the client access criteria: 1, request criteria:
The URL is: Http://localhost:8080/Sport/Registerbody is {c:{"uname" =xxx, "Upwd" =xxx, "Nkname" =xxx}}// The reason is to write all the data to the key C corresponding to the value, because it is convenient for us to encrypt all the data, after encryption, C corresponds to the data after the encryption, then the server can be decrypted as a whole.

2, return the standard: 2.1, registration success
{result:0}
2.2, duplicate user name:
{Result:1}
2.3, repeat nickname:
{Result:2}
2.4, other errors:
{result:100}


Design the interface today and the next blog will talk about the design of the back-end registration interface.
Now this backend login and registration interface has been completed, code GitHub address in the server-side code. The android side of the code also wrote a login, registered interface, landing functions have been achieved. The address is the Android-side code GitHub address. Welcome to All Star.

The next article has been written, linked to: from zero development of a app II Java Web backend Registration interface implementation

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.