尝试访问使用spring boot发布的url时出现404错误

时间:2016-09-25 00:12:05

标签: android angularjs post spring-boot retrofit2

晚上好,我有以下代码来实现rest / teste123服务,并且从angular-js代码调用此方法,已经使用spring-boot进行基本身份验证,我可以访问此服务。 当我尝试从我的android或postman扩展名chrome中的retrofit2访问它时,我得到404。 有人向我解释我做错了什么。 只是为了说明我指向正确的ip pc是192.168 ....而不是在调用时对localhost。 谢谢。

git reset --hard 15630f3

遵循AngularJS中的示例代码。

@RestController
public class TesteController {
    @RequestMapping(value = "/teste123", method = RequestMethod.POST)
    public Programa test(@RequestBody Programa prog) {
        System.out.println(prog);
        return new Programa();
    } 
}

这里是android上使用的界面。

$http.post("/teste123", {id: 'asd', txtPrograma: 'adsadasd'})
        .then(function (response) {
            console.log(response);
        }, function (response) {
            console.log(response);
        })

并在标题Retrofit中添加凭据,如下所示。

public interface ExecucaoService {

@POST("execucao/gravaLote")
public Call<Programa> gravaLote(@Body Programa programa);}

我仍然希望不是对问题或邮递员进行改造,而是在sptring-boot中进行的设置。 为英语道歉,我使用谷歌翻译。

0 个答案:

没有答案