History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: APF-984
Type: Improvement Improvement
Status: Open Open
Priority: Minor Minor
Assignee: Matt Raible
Reporter: Alex Coles
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
AppFuse

Upgrade Spring MVC Controllers to use annotations

Created: 17/Dec/07 03:37 PM   Updated: 10/Oct/08 08:55 AM
Component/s: Web - Spring
Affects Version/s: None
Fix Version/s: None

File Attachments: 1. Java Source File BaseController.java (6 kb)
2. Java Source File UserController.java (4 kb)



 Description  « Hide
Upgrade Spring MVC Controller classes to use annotations:
http://blog.interface21.com/main/2007/11/14/annotated-web-mvc-controllers-in-spring-25/

Form Controllers which extend BaseFormController (and in turn, Spring's SimpleFormController) can make use of the @RequestMapping annotation to define their request mappings:
 org.appfuse.web.controller.FileUploadController
 org.appfuse.web.controller.SignUpController
 org.appfuse.web.controller.UserFormController

Other controllers should be rewritten to be annotation-based controllers, with the @Controller annotation:
 org.appfuse.webapp.controller.PasswordHintController
 org.appfuse.webapp.controller.UserController

Tutorials should also be updated.

 All   Comments   Change History   FishEye      Sort Order:
Matt Raible - 17/Dec/07 03:41 PM
While I like the annotation-based features added to Spring MVC, I'm not convinced they're better than extending classes (SimpleFormController and implementing Controller). Also, does putting URLs in Java code make sense? I think it's best to discuss this on the user list and see what people think.

Marcello Teodori - 31/Jul/08 04:11 AM
Wouldn't it make sense to use a mixed approach to get the benefit of annotations while keeping URL mappings in a single location, like the one proposed here:
http://blog.springsource.com/main/2008/03/23/using-a-hybrid-annotations-xml-approach-for-request-mapping-in-spring-mvc/
?

Donny A. Wijaya - 10/Oct/08 08:49 AM
A controller that has similar BaseFormController functionalities. This controller is for Spring 2.5 annotated MVC.

Donny A. Wijaya - 10/Oct/08 08:51 AM
An example of class extending BaseController.

Donny A. Wijaya - 10/Oct/08 08:55 AM
Sorry this looks like Spam. You can delete all my comments above. I thought when I comment on each file the comments would appear next to the file. Sorry about this.

Anyway I created a BaseController for Spring Annotated MVC. I also provided an example class using this BaseController. Sorry for not providing the other classes. But the other classes are DTOs and nothing much. I hope these two classes could be helpful.

Regards

Donny