Announcement Announcement Module
No announcement yet.
Configure Spring MVC with AngularJS Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Configure Spring MVC with AngularJS

    I would like to be able to use Spring MVC as REST server and AngularJS on client side.

    I have several urls for REST :


    And i have several urls for the UI :


    Since it is AngularJS which do the trick on client side, i just want to be able to redirect all default ui urls (not the rest ones) to the index.html file used by AngularJS.

    So, in Spring MVC configuration, i would like to be able to do something like that :

    @ComponentScan(basePackages = "com.mypackage.web")
    public class WebAppConfiguration extends WebMvcConfigurerAdapter {
        public void addViewControllers(ViewControllerRegistry registry) {
        public ViewResolver viewResolver() {
            InternalResourceViewResolver resolver = new InternalResourceViewResolver();
            return resolver;
        public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
    With that, i want to delegate all the UI urls handling to AngularJS.

    I also want that if the user writes a bad url in the browser he would be redirected by Spring MVC on the index.html file and it will be AngularJS which will do the redirect on the error ui page. I have seen several projects on the web with a single index.html file, but no one handle this error case.

    I have been struggling a lot of time trying to do this trick but i can't find a solution.

    So my question is : how can i do that ? and more generally, am i wrong with this Spring MVC-AngularJS wanted configuration ?

    Very important : I use Spring MVC 3.2 and Tomcat 7.34 without web.xml (full Servlet 3.0)

    Thanks a lot