Android Restlet 404错误不存在
我正在为android做一个rest客户端,并使用 所以,当我运行我的应用程序时,我得到404错误-在试图存储我的数据时找不到。我的电脑正常运行Android Restlet 404错误不存在,android,rest,http-status-code-404,restlet,Android,Rest,Http Status Code 404,Restlet,我正在为android做一个rest客户端,并使用 所以,当我运行我的应用程序时,我得到404错误-在试图存储我的数据时找不到。我的电脑正常运行 package com.example.app; import org.restlet.resource.ClientResource; import android.util.Log; import com.example.app.models.Accounts; import com.example.app.models.Accou
package com.example.app;
import org.restlet.resource.ClientResource;
import android.util.Log;
import com.example.app.models.Accounts;
import com.example.app.models.AccountsResource;
public class ServerConection {
private AccountsResource resource;
public ServerConection(){
ClientResource cr = new ClientResource("http://192.168.1.2:8080/api/accounts/");
resource = cr.wrap(AccountsResource.class);
}
public void send(Accounts account){
resource.store(account);
}
}
public interface AccountsResource {
@Get
public Accounts retrieve();
@Put
public void store(Accounts account);
@Delete
public void remove();
}
LogCat
10-18 19:55:12.658: E/AndroidRuntime(10290): FATAL EXCEPTION: Timer-0
10-18 19:55:12.658: E/AndroidRuntime(10290): Not Found (404) - Not Found
10-18 19:55:12.658: E/AndroidRuntime(10290): at org.restlet.resource.ClientResource$1.invoke(ClientResource.java:1663)
10-18 19:55:12.658: E/AndroidRuntime(10290): at $Proxy4.store(Native Method)
10-18 19:55:12.658: E/AndroidRuntime(10290): at com.example.app.ServerConection.send(ServerConection.java:26)
10-18 19:55:12.658: E/AndroidRuntime(10290): at com.example.app.AccountIntentService.sendAccount(AccountIntentService.java:56)
10-18 19:55:12.658: E/AndroidRuntime(10290): at com.example.app.AccountIntentService.access$1(AccountIntentService.java:55)
10-18 19:55:12.658: E/AndroidRuntime(10290): at com.example.app.AccountIntentService$2.run(AccountIntentService.java:44)
10-18 19:55:12.658: E/AndroidRuntime(10290): at java.util.Timer$TimerImpl.run(Timer.java:284)
您应该检查服务器端应用程序的日志,可能是应用程序中的URL错误 正如Andy在他与account/s的评论中提到的,您确定URL可能不是
http://192.168.1.2:8080/api/account/
(单数)是否改为
仔细检查URL,如果问题仍然没有解决,那么我们需要查看服务器日志。服务器端发生了什么?这也是您的代码,或者您是否有来自服务器的任何日志来指示问题可能是什么?如果您使用另一个工具(比如curl)执行HTTP请求,会发生什么?它是否也返回404?顺便说一句,这可能与您当前的问题无关,但我发现您有一个Accounts(复数)类型的参数“account”(单数)。