springboot中页面跳转后发送异步请求地址错误
A页面要进行跳转的地方
<el-link :href="'/info/'+item.novelId" :underline="false">{{item.novelName}}</el-link>
控制层
@RequestMapping("/info/{novelId}")
public String toInfoArg(@PathVariable String novelId, Model model) {
model.addAttribute("novelId", novelId);
return "info";
}
在info页面取值并发送异步请求
queryNovelAndList() {
const novelId = "[[${novelId}]]";
console.log(novelId)
axios({
method: "GET",
url: "novels/info/" + novelId
}).then(resp => {
console.log(resp.data)
})
}
异步请求的控制层
@RestController
@RequestMapping("novels")
public class NovelController {
@Autowired
private NovelService novelService;
//查询info页面的数据
@GetMapping("info/{novelId}")
public DataProtocol selInfoNeed(@PathVariable int novelId) {
NovelInfo novelInfo = novelService.selInfoNeed(novelId);
return new DataProtocol(CODE_SUCCESS, SELECT_SUCCESS, novelInfo);
}
}
然而在浏览器中检查发现异步请求的地址不对:
http://localhost/info/novels/info/149562
正确的请求地址应该是:
http://localhost/novels/info/149562
不知道为什么多了个info出来,怎么解决多出来的info?