views:

211

answers:

1

I get this error whenever I try to view my tutorial app in the browser

WARNING: No mapping found for HTTP request with URI [/HelloWorld.Web] in DispatcherServlet with name 'dispatcher'

That just means the request is being received by the dispatcher servlet but it can't forward it to a controller.

But I can't seem to know where the problem is. I think I've mapped this correctly:

<bean id="urlMapping" 
     class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
     <property name="mappings">
        <props>
           <prop key="/HelloWorld.Web">indexController</prop>
        </props>
     </property>    
</bean>

<bean id="indexController" class="com.helloworld.controller.IndexController">
    <property name="artistDao" ref="artistDao"/>    
    <property name="methodNameResolver">
        <bean class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
            <property name="alwaysUseFullPath" value="true"/>
            <property name="mappings">
                <props>
                    <prop key="/HelloWorld.Web">getAllArtists</prop>
                </props>
            </property>
        </bean>
    </property>
</bean>

I am using Spring 2.5.6 and Bea Weblogic Server 9.2

Here's my web.xml

<web-app id="WebApp_ID" version="2.4" 
         xmlns="http://java.sun.com/xml/ns/j2ee" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt;  

    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>           
    </servlet>

    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
</web-app>

Here's the IndexController

public class IndexController extends MultiActionController {

    private ArtistDao artistsDao;
    public ModelAndView getAllArtists(HttpServletRequest request, HttpServletResponse response) throws SQLException{
        ModelAndView mav = new ModelAndView();
        mav.setViewName("index");
        List<Artist> artists = artistsDao.getAll();
        mav.addObject("artists", artists);
        return mav;
    }
    public void setArtistsDao(ArtistDao artistsDao) {
        this.artistsDao = artistsDao;
    }

}
A: 

I'm not really sure about this but I think the problem is in the following entry in web.xml:

<servlet-mapping>
     <servlet-name>dispatcher</servlet-name>
     <url-pattern>/</url-pattern>
</servlet-mapping>

The Servlet 2.4 Specification is a total blur (IMO) regarding mapping requests to servlets and the above declaration means the "default" servlet of the application, in which case the servlet path is the request URI minus the context path and the path info is null (whatever the heck that means).

So, if you replace the above with the following, does it change anything?

<servlet-mapping>
     <servlet-name>dispatcher</servlet-name>
     <url-pattern>/*.Web</url-pattern>
</servlet-mapping>
dpb