1.用postman調(diào)試接口的過程中,出現(xiàn)404,第一確認(rèn)類上注解是@RestController
?不然在測試的時(shí)候會(huì)出現(xiàn)500
2.確定方法上有沒有聲明PostMapping或者GetMapping
3.uri路徑確認(rèn)沒問題
@RestController
@RequestMapping("/test")
public class TestController {
@GetMapping //去掉GetMapping就會(huì)出現(xiàn)404
public Result test(){
SysUser sysUser= UserThreadLocal.get();
System.out.println(sysUser);
return Result.success(null);
}
}
加上@GetMapping測試成功
文章來源:http://www.zghlxwxcb.cn/news/detail-514552.html
?總結(jié):404找不到資源,無非就是接口路徑,提交方式、參數(shù)類型、返回結(jié)果類型有問題。
而我們接口返回結(jié)果要json格式的數(shù)據(jù),所以添加@ResponseBody或者使用@RestController即可。文章來源地址http://www.zghlxwxcb.cn/news/detail-514552.html
到了這里,關(guān)于postman測試接口在URL配置正確的情況下出現(xiàn)404或者500錯(cuò)誤的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!