reactjs - React-Router issues when serving React App with Spring Boot -
i'm needing serve react app spring boot. working root url - localhost:8080/
, of course none of sub-routes recognized spring controller.
i'm not sure how react routing , spring request mapping line without hard-coding in every possible route map index.html
- , of routes have variable sub-routes.
here homecontroller
serves index.html
@controller public class homecontroller { @requestmapping(value = "/") public string index() { return "index.html"; } }
here routing render in react app
const root = ({ store }) => ( <provider store={store}> <router history={browserhistory}> <route path="/" component={app}> <indexredirect to="users"/> <route path="/org" component={orgsearch}> {<route path="/org/:orgid" component={org}/>} </route> <route path="/users" component={usersearch}> {<route path="/users/:userid" component={user} />} </route> </route> </router> </provider> )
any appreciated!
edit: tried adding wildcard functionality, , presenting strange behavior. here updated code homecontroller
.
@controller public class homecontroller { @requestmapping(value = {"/", "/users/**", "/org/**"}) public string index() { return "index.html"; } }
i can access /
, /users
not /users/
or /users/2545
.
here error when try access latter.
2017-04-14 09:21:59.896 error 58840 --- [nio-8080-exec-3] o.a.c.c.c.[.[.[/].[dispatcherservlet] : servlet.service() servlet [dispatcherservlet] in context path [] threw exception [circular view path [index.html]: dispatch current handler url [/users/index.html] again. check viewresolver setup! (hint: may result of unspecified view, due default view name generation.)] root cause javax.servlet.servletexception: circular view path [index.html]: dispatch current handler url [/users/index.html] again. check viewresolver setup! (hint: may result of unspecified view, due default view name generation.) @ org.springframework.web.servlet.view.internalresourceview.prepareforrendering(internalresourceview.java:205) ~[spring-webmvc-4.3.7.release.jar:4.3.7.release] @ org.springframework.web.servlet.view.internalresourceview.rendermergedoutputmodel(internalresourceview.java:145) ~[spring-webmvc-4.3.7.release.jar:4.3.7.release] @ org.springframework.web.servlet.view.abstractview.render(abstractview.java:303) ~[spring-webmvc-4.3.7.release.jar:4.3.7.release] @ org.springframework.web.servlet.dispatcherservlet.render(dispatcherservlet.java:1282) ~[spring-webmvc-4.3.7.release.jar:4.3.7.release] @ org.springframework.web.servlet.dispatcherservlet.processdispatchresult(dispatcherservlet.java:1037) ~[spring-webmvc-4.3.7.release.jar:4.3.7.release] @ org.springframework.web.servlet.dispatcherservlet.dodispatch(dispatcherservlet.java:980) ~[spring-webmvc-4.3.7.release.jar:4.3.7.release]
Comments
Post a Comment