1

Here's my Web.xml

<display-name>Spring MVC Application</display-name>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/application-context.xml</param-value>
</context-param>

<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<servlet>
    <servlet-name>mvc-dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

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

Here is the code: application-context.xml:

<context:property-placeholder location="classpath:jdbc.properties" system-properties-mode="ENVIRONMENT"/>
<context:component-scan base-package="com.springapp.mvc.repository"/>

<tx:annotation-driven transaction-manager="transactionManager"/>

<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory">

    </property>
</bean>

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value = "${jdbc.driverClassName}"/>
    <property name="url" value="${jdbc.databaseurl}"/>
    <property name="username" value="${jdbc.username}"/>
    <property name="password" value="${jdbc.password}"/>
</bean>

<bean id = "sessionFactory" class = "org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref = "dataSource"/>
    <property name="configLocation" value="classpath:hibernate.cfg.xml"/>
    <property name="configurationClass" value="org.hibernate.cfg.AnnotationConfiguration"/>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.dialect">${jdbc.dialect}</prop>
            <prop key="hibernate.connection.charSet">UTF-8</prop>
        </props>
    </property>
</bean>

mvc-dispatcher-servlet.xml:

<context:component-scan base-package="com.springapp.mvc.controller"/>

<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="prefix" value="/WEB-INF/pages/"/>
    <property name="suffix" value=".jsp"/>
</bean>



<mvc:resources mapping="/res/**" location="/res/"/>

When I try to run the project server emits a warning: WARNING org.springframework.web.servlet.PageNotFound.noHandlerFound No mapping found for HTTP request with URI [/] in DispatcherServlet with name 'mvc-dispatcher'

Please tell me what went wrong.

Evgenia
  • 335
  • 2
  • 12
  • Possible duplicate of [Why does Spring MVC respond with a 404 and report "No mapping found for HTTP request with URI \[...\] in DispatcherServlet"?](http://stackoverflow.com/questions/41577234/why-does-spring-mvc-respond-with-a-404-and-report-no-mapping-found-for-http-req) – BalusC Jan 13 '17 at 12:48

2 Answers2

0

Try to remove hyphen "-" in "mvc-dispatcher" to "mvcdispatcher".

Mai Tan
  • 21
  • 3
  • Its just a logical name given to the servlet handling the request for the url-pattern and removing the - might not make any difference in this context – Balaji Katika May 11 '15 at 04:18
0

Update the url-pattern tag as below. Note the asterisk(*) after slash (/)

<url-pattern>/*</url-pattern>
Balaji Katika
  • 2,835
  • 2
  • 21
  • 19