• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Spring MVC java configuration question

Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm looking at a Spring MVC Java configuration file from Craig Walls' Spring In Action volume 4:

The addResourceHandlers(...) method is equivalent to the XML configuration element <mvc:resources.../> element. I'm use to seeing something like
<mvc:resources mapping="/resources/**" location="/resources"/> for static resources located in /webapp/resources/, as is the case in the book's projects. In this case, the call above should equate to

according to my understanding of the Spring documentation. I'm wondering why the call in the WebConfig.java file above seems to work?
Posts: 3648
Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the same question.

Given the sample book's code, there are some xml in the /WEB-INF/spring folder but I'm not if those actually make the app work.

I did a testing app that set up just like his using JavaConfig.... and when I run it, it didn't work got a 404 and in the server log got a "No spring web app initializer found in classpath" or something like that.

Then comparing his code to other people's code about web app initializer, I see a big? difference:
Craig's code extends AbstractAnnotationConfigDispatcherServletInitializer while other people implements WebApplicationInitializer

Does extending AbstractAnnotationConfigDispatcherServletInitializer have the same effect as implementing WebApplicationInitializer??

Mike Tabak
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe the XML files are there for information only, to show how some of the config would be done for an application using XML configuration. As far as AbstractAnnotationConfigDispatcherServletInitializer vs. WebApplicationInitializer go, this may help: AbstractAnnotationConfigDispatcherServletInitializer and WebApplicationInitializer
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic