RT
后端java
前端Vue
如果是使用axios做交互插件,可以尝试做以下配置
this.$http.get(url, data, config)
.then(res => {
// success
})
.catch((err) => {
// fail
if (err.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
// 出现状态码为2xx以外的时候运行
} else if (err.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
// 这个虽然官方说是没有响应的时候运行的,但是我实际测试没试出来过
} else {
// Something happened in setting up the request that triggered an Error
}
console.log(error.config);
})
前端可以根据后台返回的状态码进行一个判断,出现特定状态码就跳转至维护页面
13 回答12.8k 阅读
7 回答2k 阅读
4 回答1.3k 阅读✓ 已解决
4 回答1.2k 阅读✓ 已解决
3 回答1.1k 阅读✓ 已解决
1 回答2.5k 阅读✓ 已解决
2 回答1.2k 阅读✓ 已解决
非常感谢大家,问题已解决,来说一下我的做法,因为服务器大小有限,没办法做Websocket,而且想可以随意操作是否出现维护页面,所以在服务器前端根目录下放置了一个json文件,这个json文件当作配置文件,可以配置是否维护,维护的时间段,维护页面显示的内容,然后通过前端请求读取来判断,也是一个没有办法的办法吧