react-router browserHistory刷新页面4

2018-12-28  本文已影响0人  鹅鹅鹅_

造成404的原因相信你已经搞得很明白了,也知道了几种解决办法。

location /xxx {
  try_files $uri $uri/ /xxx/index.html;
}
    public void start() {

        get("/xxx", (request, response) -> memberCentre(request, response));
    }

    public String memberCentre(Request request, Response response) {
        response.redirect("/index.html");
        return "";
    }
public String memberCentre(Request request, Response response) {
        response.sendfile("/index.html");
        return "";
}
static {
        StringBuffer sb = new StringBuffer();
        try (BufferedReader br = new BufferedReader(new FileReader(react_index))) {
            String data = null;
            while ((data = br.readLine()) != null) {
                sb.append(data);
            }
        } catch (FileNotFoundException e1) {
            LOG.error("Get react index.html failed, " + react_index + " not exist", e1);
        } catch (IOException e2) {
            LOG.error("Get react index.html failed, " + react_index, e2);
        }
        index_content = sb.toString();
    }

    public void start() {

        get("/accounts/detail/*", (request, response) -> accountsDetail(request, response));
    }

    public String accountsDetail(Request request, Response response) {
        return index_content;
    }

上一篇 下一篇

猜你喜欢

热点阅读