AnsweredAssumed Answered

Spring URL Mappings in custom-slingshot-application-context

Question asked by sanjaymk on Jun 11, 2011
Hello -

I would like to map a set of urls to a custom SPRING MVC controller class.  I defined the mapping in the custom-slingshot-application-context.xml file.  The log files are registering the mappings to the handlers, but when I make a request, the request is directly going to the jsp page instead of being directed to the controller.

Below is my custom-slingshot-application-context file located in \shared\classes\alfresco\web-extension


<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>

      <!– Override WebScript Messages - add slingshot application messages –>
   <bean id="webscripts.cop.resources" class="org.springframework.extensions.surf.util.ResourceBundleBootstrapComponent">
      <property name="resourceBundles">
         <list>
            <value>alfresco.web-extension.messages.demo</value>         
         </list>
      </property>
   </bean>
  
   <bean id="copframeworkHandlerMappings" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
      <property name="mappings">
         <value>
         /**/doCommodityCodes/**=findComCode
         /**/commodity_search/**=comCodeSearch
         </value>
      </property>
   </bean>
    
   <bean id="findComCode" class="gov.xxx.xxx.CommodityCodeController"/>
   
   <bean id="comCodeSearch" class="gov.xxx.xxx.CommodityCodeSearchController"/>
   
   <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="prefix" value="/WEB-INF/views/"/>
      <property name="suffix" value=".jsp"/>
   </bean>
  
</beans>

The share log file has these messages during startup


[org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] Mapped URL path [/dologout/**] onto handler
[b][org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] Mapped URL path [/**/commodity_search/**] onto handler [gov.phila.city.CommodityCodeSearchController@128c8a2]
[org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] Mapped URL path [/**/doCommodityCodes/**] onto handler [gov.phila.city.CommodityCodeController@5ed41e]
[org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] Mapped URL path [/share/page/commodity_search/**] onto handler [gov.phila.city.CommodityCodeSearchController@128c8a2]
[/b]

When I make a request http://localhost:8080/share/page/commodity_search, the logs are


[color=#FF0000][i]19:43:15,453 DEBUG [org.springframework.web.servlet.handler.SimpleUrlHandlerMapping] Mapping [/commodity_search] to handler 'org.springframework.extensions.surf.mvc.UrlViewController@17c2262'
19:43:15,453 DEBUG [org.springframework.web.servlet.DispatcherServlet] Last-Modified value for [/share/page/commodity_search] is: -1
19:43:15,453 DEBUG [org.springframework.web.servlet.DispatcherServlet] DispatcherServlet with name 'Spring Surf Dispatcher Servlet' processing GET request for [/share/page/commodity_search][/i][/color]
19:43:15,453 DEBUG [org.springframework.web.servlet.DispatcherServlet] Rendering view [org.springframework.web.servlet.view.InternalResourceView: name 'commodity_search'; URL [/WEB-INF/views/commodity_search.jsp]] in DispatcherServlet with name 'Spring Surf Dispatcher Servlet'
19:43:15,453 DEBUG [org.springframework.web.servlet.view.InternalResourceView] Forwarding to resource [/WEB-INF/views/commodity_search.jsp] in InternalResourceView 'commodity_search'
19:43:15,484 DEBUG [org.springframework.web.servlet.DispatcherServlet] Successfully completed request


When I was composing this message, I also noted that there are a whole lot of Rejected Bean Messages in the log file, which are basically "un-mapping" all the urls to controllers.


[color=#FF0000][b]
19:04:29,312 DEBUG [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] Rejected bean name 'copframeworkHandlerMappings': no URL paths identified
19:04:29,312 DEBUG [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] Rejected bean name 'findComCode': no URL paths identified
19:04:29,312 DEBUG [org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping] Rejected bean name 'comCodeSearch': no URL paths identified[/b][/color]


Any suggestions or help in solving this issue is highly appreciated.

Thanks,
Sanjay.

Outcomes