我有一个Spring Boot后端,并对前端应用程序有反应。我在我的应用程序上使用了反应路由器。我不确定如何配置以在我的Spring Boot应用程序中查看我的反应页面。
我看了网上,却找不到任何可行的方法。
app.js(一些代码)
const App = () => (
<div>
<AppNavBar />
<div className="bodymain">
<Router history={history}>
<Switch>
<Route path="/" exact={true} component={Home}/>
<Route path="/public" component={Public}/>
<Route path="/addveh" component={VehiclePage}/>
<Route path="/tagloca" component={VinFindPage} />
<Route path="/allbmwreaders" component={AllBmwreaders} />
<Route path="/updateVehTag" component={UpdateVeh}/>
</Switch>
</Router>
</div>
</div>)
export default withRouter(App)
webconfig.java(一些代码)
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry){
registry.addResourceHandler("/*.js").
addResourceLocations("/target/classes/public/");
registry.addResourceHandler("/").
addResourceLocations("/index.html");
}
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/").setViewName("/index");
}
@Override
// configure static file handling
public void configureDefaultServletHandling
(DefaultServletHandlerConfigurer configurer) {
configurer.enable();
}
使用Spring Boot应用程序时,我希望能够查看我的反应页面。我在target / classes / public目录中构建了react应用。