Mark Spritzler wrote:Both tags provide different classes to work on different annotations and also give you different set of bean classes that is needed.
So for instance component-scan provides things like scanning for @Component, @Controller, @Service, @Repository, @Autowired, @Inject, @PostConstruct etc, it adds BeanPostProcessors and such that scans for those and some more annotations, it does not for example, act on/search for @RequestMapping, @SessionAttribute, @RequestBody, @ResponseBody, not provide an
class. No, because those classes and act/on are provided with the mvc:annotation-driven tag. Now it also doesn't mean that xml configuration can overwrite some of that stuff too.
Hope that helps. Basically they provide difference stuff, those two configurations.
Mark
In this showcase you'll see the following in action:
The simplest possible @Controller
Mapping Requests
Obtaining Request Data
Generating Responses
Message Converters
Rendering Views
Type Conversion
Validation
Forms
File Upload
Exception Handling
Mark Spritzler wrote:Yes the resources mapping makes putting links to css and javascript, well imports, so much easier to type and not have to do things like {context.getPath} or the similar in your html, it can now just be "resources/js/myjs.js"
But it doesn't mean you have to use "resources/js/myjs.js" in your html, you can still do {context.getPath} in your html.
In this showcase you'll see the following in action:
The simplest possible @Controller
Mapping Requests
Obtaining Request Data
Generating Responses
Message Converters
Rendering Views
Type Conversion
Validation
Forms
File Upload
Exception Handling
So things like MessageConverters, TypeConversion, Validation those all require the mvn:annotation-driven to automatically get all of those. You can also get all those by defining each and every one as its own bean in the config file, but that would probably be a couple hundred lines of xml that you get with just one line mvc:annotation-driven.
I would say the application doesn't completely work without mvc:annotation-driven.
But you probably can run it and just get to
<mvc:view-controller path="/" view-name="home"/>
the root path because of this that is in the config file
spring-mvc-showcase / src / main / webapp / WEB-INF / spring / appServlet / controllers.xml
Hmm, I also saw in the servlet-context.xml
Which doesn't look what you posted. I am looking at the current up to date version of the app on github at https://github.com/SpringSource/spring-mvc-showcase
Mark
Don't get me started about those stupid light bulbs. |