Feb 24th, 2009, 04:50 PM
Group Controllers and Views into Modules
I'm writing some shop system and I've got problem.
I'd like to group my controllers and views into few logical modules, my directories structure looks as below:
/WEB-INF/admin - views for administrator controllers
/WEB-INF/ws - views for webservices
/WEB-INF/web - vews for normal website
com.darek.coffeine.admin - controllers for administrator
com.darek.coffeine.ws - controllers for webservices
com.darek.coffeine.web - controllers for normal website
Id like to map url calls to this groups, for example
htp://example.com/admin/index.html will execute IndexController in com.darek.coffeine.admin, but htp://example.com/index.html will execute IndexController from com.darek.coffeine.web.
What's the best solution for this problem. I've tried to make few HandlerMappings in my coffeine-servlet.xml but there are Controllers that had this same name (diffrent package), and i don't know how to bind them to addresses.
Feb 24th, 2009, 11:35 PM
If you are using annotations then you need to do something like @RequestMapping("/admin/index.htm")
if you are using BeanNameUrlHandlerMapping, then the name of your bean should be
<bean name="/admin/index.htm" class ="bla.bla.bla.admin.IndexController"/> or something like that.
Feb 25th, 2009, 02:19 AM
I'll try it when I come back to home.
But what's better. Use Annotations or Traditional Mappings? I saw that in SpringFramework 3 there will be much more Annotations.
Feb 25th, 2009, 11:17 AM
I prefer annotations because is less verbose, and actualy i remember reading somewhere that in spring 3 they will deprecated all the non annotation web controllers but im not sure of that.
Tags for this Thread