对于前端Android:
1.本例子采用的网络通信框架为OkHttp。
需要引入jar包为:implementation ‘com.squareup.okhttp3:okhttp:3.8.1’
2.解析JSON用的为Gson(当然可以采取自带的解析方式,Gson更为方便,且官方也推荐)
需要引入jar包为:implementation ‘com.google.code.gson:gson:2.8.5’
3.还需要添加网络权限:
<uses-permission android:name="android.permission.INTERNET" />
xml文件代码:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="50dp"
tools:context=".MainActivity">
<EditText
android:id="@+id/et_userName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="用户名"
android:inputType="text"
android:maxLines="1"
android:singleLine="true"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"/>
<EditText
android:id="@+id/et_userPwd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="密码"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true"
android:layout_