Решено, для удаления тега Hash # To URL, используя Jhipster и React [Spring + ReactJs]. Я использую ссылку @ Gaël Marziou сказал мне.
следует за модификациями:
== Реагировать ==
1 - com / mycompany / myapp / src / main / webapp / app / app.tsx
import { BrowserRouter as Router } from 'react-router-dom';
// import { HashRouter as Router } from 'react-router-dom';
2 - com / mycompany / myapp / src / main / webapp / index.html
<!-- <base href="./"/> -->
<base href="/"/>
3 - com / mycompany / myapp / webpack / webpack.prod.js
},
devServer: {
historyApiFallback: true, /*insert this line - only use for develop*/
stats: options.stats,
hot: true,
contentBase: './build/www',
proxy: [{
context: [
...
== JAVA ==
4 - com / mycompany / myapp / src / main / java / br / com / MyApp / config / WebConfigurer.java
@Bean
public Html5RouteFilter html5RouteFilter() {
return new Html5RouteFilter();
}
5 - com / mycompany / myapp / src / main / java / br / com / MyApp / web / Html5RouteFilter.java
ВАМ НУЖНО СОЗДАТЬ ЭТОТ ФАЙЛ
пакет com.mycompany.myapp.web;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.filter.OncePerRequestFilter;
import javax.servlet.FilterChain;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.regex.Pattern;
/**
* Filter that distinguishes between client routes and server routes when you don't use '#' in client routes.
*/
public class Html5RouteFilter extends OncePerRequestFilter {
private Logger log = LoggerFactory.getLogger(getClass());
// These are the URIs that should be processed server-side
private static final Pattern PATTERN = Pattern.compile("^/((api|content|i18n|management|swagger-ui|swagger-resources)/|error|h2-console|swagger-resources|favicon\\.ico|v2/api-docs).*");
@Override
protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response,
FilterChain filterChain)
throws ServletException, IOException {
if (isServerRoute(request)) {
filterChain.doFilter(request, response);
} else {
RequestDispatcher rd = request.getRequestDispatcher("/");
rd.forward(request, response);
}
}
protected static boolean isServerRoute(HttpServletRequest request) {
if (request.getMethod().equals("GET")) {
String uri = request.getRequestURI();
if (uri.startsWith("/app")) {
return true;
}
return PATTERN.matcher(uri).matches();
}
return true;
}
}
=== END ==
теперь будь счастлив