background

Today, when I was writing a self-help machine scan code to jump to the corresponding wechat public account page, there was a detail page written by the route of Vue, with # in the address for example

https://open.weixin.qq.com/connect/oauth2/authorize?appId=wx6a1f86436904cd12&redirect_uri=https://wwww.xxx.cn/home/initi al#/detail?a=xx&b=xx&response_type=code&scope=snsapi_base&state=100&connect_redirect=1#wechat_redirect&response_type=cod e&scope=snsapi_base&state=100&connect_redirect=1#wechat_redirectCopy the code

Of course, the actual redirect_URI needs encode. After scanning the code in wechat, we found that the parameters behind initial## were lost. After checking the solution, it was ok to change the VUE route from hash to history mode. After switching to history mode, the page cannot render, so you have to start from the background

To solve

Write a redirect without # and redirect to the current request. If you want to redirect to the current request, just do it

The redirect_uri instead

&redirect_uri=https://wwww.xxx.cn/home/initial/detail?a=xx&b=xx
Copy the code

Write a background request

@RequestMapping("/home/initial/detail") public String detail(String a, String b) { return "redirect:/home/initial#/detail? a=" + a + "&b=" +b; }Copy the code

Curve of national salvation