简体   繁体   中英

Spring-Social: No mapping found for HTTP request

Today I began migrating the sample code in https://github.com/spring-projects/spring-social-samples/tree/master/spring-social-showcase-sec-xml to one of my larger spring projects, it took some doing until I was able to compile without error but I finally made it to that point. However now I cannot access any of the URLs that should be mapped to the social controllers:

WARN [http-8080-2] PageNotFound.noHandlerFound(1108) | No mapping found for HTTP request with URI [/junkie/app/signin/facebook] in DispatcherServlet with name 'dispatcher' WARN [http-8080-2] PageNotFound.noHandlerFound(1108) | No mapping found for HTTP request with URI [/junkie/app/connect/facebook] in DispatcherServlet with name 'dispatcher'

I checked to make sure the controllers where initialized so I autowired them in a controller and they appear to be so I am at a loss now. After spending a few hours banging my head against the wall I have come here to hopefully find some help. Here is how things are configured: http://pastebin.com/tPi5Mtny

I had the same problem. I solved it by putting the connectController bean into dispatcher-servlet.xml. In your case, the bean is instantiated in the root application context rather than the dispatcher servlet dedicated context. Although the root application context is the parent context of the servlet context, it does not mean the servlet can automatically access the bean in its parent context. Revealed by this thread . Your dispatcher never know there is a connectController.

You may then ask why the showcase project works? (The showcase project url is updated: url ). Its connectController bean is also declared there in the same social.xml file that loaded in the root application context. How come its dispatcher servlet has access to the controller bean? If you watch closer, you may find the showcase doesn't have the dispatcher-servlet.xml file, and in its web.xml, it declares its dispatcher servlet as below:

<servlet>
    <servlet-name>appServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value></param-value>
    </init-param>
    ...
</servlet>

With a blank value for contextConfigLocation, it is saying the servlet does not have a dedicated context and will just use the root application context.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM