How to do wildcard bean mapping in Spring MVC?
I'm trying to do RESTful URL mapping in Spring 2.5. This essentially
means: /fetch/(something) should all be matched to controller fetch
And the controller will do something according the parameter (something)
I add this to my spring config:
<bean id="fetchController" class="(package).fetchController"
scope="singleton"/>
<bean id="fetchService"
class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key="/fetch/*">fetchController</prop>
</props>
</property>
</bean>
and add the following to my web.xml
<servlet-mapping>
<servlet-name>springGlobal</servlet-name>
<url-pattern>/fetch/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>springGlobal</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
But this doesn't seem to be correct. The log says:
org.springframework.web.servlet.PageNotFound - No mapping found for HTTP
request with URI [/fetch/charts] in DispatcherServlet with name
'springGlobal'
No comments:
Post a Comment