node 或nuxt请求接口时提示Request path contains unescaped characters如何处理

ppylox
·5/30/2021·0 阅读
AI 摘要模型根据正文自动生成,仅供参考

Node或Nuxt请求接口提示“Request path contains unescaped characters”,原因是请求路径含中文等未转义字符。解决方法是前端用encodeURI对参数编码,如`'/pages/getList/tags/' + encodeURI(params.cate)`;后端用URLDecoder.decode(cate, "utf-8")解码后处理。

node 或nuxt请求接口时提示Request path contains unescaped characters,从字面意思理解就是路径包含未转义字符,也就是请求的路径中包含中文。

处理方法就是对中文进行编码,具体操作就是将参数通过encodeURI(params.cate) 来实现,然后再接口上通过URLDecoder.decode(cate, "utf-8") 来解码就可以了。

前端:

'/pages/getList/tags/' + encodeURI(params.cate) 


后端:

count = pagesSerice.getCountByTags(URLDecoder.decode(cate, "utf-8"));

相关文章

评论 (0)

暂无评论,来写第一条吧