背景
今天在寫(xiě)一個(gè)自助機(jī)掃碼跳轉(zhuǎn)到對(duì)應(yīng)的微信公眾號(hào)頁(yè)面時(shí),有個(gè)詳情頁(yè)是vue的路由寫(xiě)的,地址中帶#例如
https://open.weixin.qq.com/connect/oauth2/authorize?appId=wx6a1f86436904cd12&redirect_uri=https://wwww.xxx.cn/home/initial#/detail?a=xx&b=xx&response_type=code&scope=snsapi_base&state=100&connect_redirect=1#wechat_redirect&response_type=code&scope=snsapi_base&state=100&connect_redirect=1#wechat_redirect
,當(dāng)然實(shí)際中的redirect_uri是需要encode一下的,再微信中掃碼后發(fā)現(xiàn)initial## 號(hào)后邊的參數(shù)均丟失了,查了解決方法說(shuō)是將vue路由由hash換為history模式就可以,但是讓前端小哥看了之后,換成歷史模式后頁(yè)面都沒(méi)法渲染了,沒(méi)辦法只能從后臺(tái)入手
解決
前端不行了,只能求助后臺(tái)了,由于就是apache的系統(tǒng),也木得ngnix,就使用最簡(jiǎn)單的redirect重定向了,寫(xiě)一個(gè)不帶#號(hào)的請(qǐng)求,再redirect到目前的請(qǐng)求,說(shuō)干就干
把redirect_uri改為
&redirect_uri=https://wwww.xxx.cn/home/initial/detail?a=xx&b=xx
寫(xiě)一個(gè)后臺(tái)的請(qǐng)求
@RequestMapping("/home/initial/detail")
public String detail(String a, String b) {
return "redirect:/home/initial#/detail?a=" + a + "&b=" +b;
}
曲線救國(guó)