上午使用改進爲我與服務器的連接,我的應用程序有登錄頁面和註銷頁面在登錄期間我從文本框中獲取值並使用POST請求發送到服務器它工作正常,改裝錯誤:Android中的500內部服務器錯誤
public void LoginUser(View v)
{RestAdapter adapter = new RestAdapter.Builder()
.setEndpoint(ROOT_URL)
.build();
WashAPI api = adapter.create(WashAPI.class);
api.LoginUser(
Email.getText().toString(),
Password.getText().toString(),
//Creating an anonymous callback
new Callback<Response>() {
@Override
public void success(Response result, Response response) {
//On success we will read the server's output using bufferedreader
//Creating a bufferedreader object
BufferedReader reader = null;
//An string to store output from the server
String output = "";
try {
//Initializing buffered reader
reader = new BufferedReader(new InputStreamReader(result.getBody().in()));
//Reading the output in the string
output = reader.readLine();
} catch (IOException e) {
e.printStackTrace();
}
接口簽到
public interface WashAPI {
@FormUrlEncoded
@POST("/xxx/yyy/signin")
public void LoginUser(
@Field("email") String email,
@Field("password") String password,
Callback<Response> callback);
}
這工作好
我的服務器API登錄後返回我一個道理,在signout的時候,我需要發送令牌,所以我的會話得到了體驗。
爲signout
代碼public void signout(View v)
{
Log.d("insidetoken",t);
RestAdapter adapter = new RestAdapter.Builder()
.setEndpoint(ROOT_URL)
.build();
SignoutAPI api = adapter.create(SignoutAPI.class);
api.signout(t,
new Callback<Response>() {
@Override
public void success(Response result, Response response) {
BufferedReader reader = null;
String output = "";
try {
reader = new BufferedReader(new InputStreamReader(result.getBody().in()));
output = reader.readLine();
} catch (IOException e) {
e.printStackTrace();
}
接口signout
public interface SignoutAPI {
@FormUrlEncoded
@POST("/xxx/yyy/zzz/signout")
public void signout(
@Field("token") String token,
Callback<Response> callback);
}
我的代碼是相同的兩個登入和SIGOUT
但簽到它的工作原理和signout它給了我RETROFIT錯誤:500內部服務器錯誤
什麼問題? –
爲什麼在註銷操作期間發生內部服務器錯誤? – livemaker
因爲在服務器上有錯誤 –