views:

51

answers:

1

What I would like to do is have a common Service class which has various methods such as "search" "retriveByID" etc. Ideally this class would consume the service parameters and populate a request object and hand off to the appropriate data source handler.

I want to instantiated a service class as a Spring bean with different request handlers depending on the domain object being searched. Then using bean BeanNameUrlHandlerMapping invoke a different Service class based on the URL.

<bean name="/sequence/*" class="org.dfci.cccb.services.SearchServiceImpl">
    <property name="searchHandler">
     ....

My problem is that when i try to do this I can't use method level RequestMapping annotations to select the appropriate method of the service class.

@RequestMapping("*/search/")
QueryResult search(...

Alternatively is it possible to inject annotation values through bean definitions?

UPDATE There is also a Springsource article on this topic: http://blog.springsource.com/2008/03/23/using-a-hybrid-annotations-xml-approach-for-request-mapping-in-spring-mvc/

A: 

Was very surprised to learn that it actually works. Just remove the trailing slash:

@RequestMapping("*/search") 

And this works too:

@RequestMapping("search") 
axtavt
That's what I thought, too, but I couldn't find it in the docs.
skaffman
you don't even need the wildcard this works: @RequestMapping("/search")
nialloc