springboot正常启动项目,访问接口均正常,新增一接口请求界面路径,访问该接口报错404
idea springboot
http://localhost:8080/cuer/apSw?ad=2893e6fce42&_=161607509 404
接口没被扫描到
百度说是接口所在包放置位置不对,导致接口没被扫描到,但是我的情况是系统原本存在的接口都可以访问到,并且新接口所在位置与旧接口所在位置一致。且查看新接口包与 spring boot启动类的位置符合可被扫描到情况,故排除新接口包放置位置不对的情况
配置或代码写法问题
查看后端接口代码写法没错
查看调用后端接口传参是否错误(接口有参数,直接不传参http://localhost:8080/cuer/apSw,打断点 访问接口,可以进入到接口,说明接口没错)断点往下打,发现是return 页面报404 ,比对后发现,页面路径对应根本没页面,修改页面路径重新访问,成功。
@Slf4j
@Controller
@RequestMapping(value = {"/customer"})
@AllArgsConstructor
public class CerCustomerController {
private final PsionsUtil pnsUtil;
private final ICCredService crdService;
private final ICrEvalService ervice;
/**
* 跳转到列表界面
*
* @return
*/
@GetMapping("/index")
public String customerCredIndex() {
return "/business/customer/index";
}
/**
* 跳转到查看界面
*
* @return
*/
@GetMapping("/apeShw")
public String apseShw(String ad, Model model) {
model.addAttribute(“apId”, aId);
if (“CD”.equals(perUtil.getreTpe())) {
return “/bess/cuer/evfo”;
} else {
CeerVo ceo = creice.gtCByAlyId(ad);
model.addAttribute(“cd”, cVo);
return “/busis/cr/co”;
}
}
}
最后
找了挺久,有点坑哦,前端调用写错字母,就乌龙了