1

enter image description heremy web.xml file

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>Spring-practise-1</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <description></description>
    <display-name>offers</display-name>
    <servlet-name>offers</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>offers</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>

My offers-servlet.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd">


    <context:component-scan base-package="com.prasad.madge.controller">
    </context:component-scan>

    <mvc:annotation-driven></mvc:annotation-driven>


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

</beans>

My Controller

    package com.prasad.madge.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class OffersController {

    @RequestMapping("/")
    public String showHome(){
        return "home";
    }

}

Error Logs :

....

INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Apr 17, 2016 1:03:23 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2434 ms
Apr 17, 2016 1:03:23 PM org.springframework.web.servlet.PageNotFound noHandlerFound
WARNING: No mapping found for HTTP request with URI [/Spring-practise-1/] in DispatcherServlet with name 'offers'

I have also tried putting "/*" and "/" in URL mapping still it did'nt worked for me.

I have checked my folder structure they seem perfect. I am using Spring 4 jar files.

Prasad Madge
  • 71
  • 1
  • 14
  • How are you running the application? are you using an embedded server, also which URL are you hitting. – 11thdimension Apr 17 '16 at 07:49
  • Please provide the URL which you are hitting. Also show your project structure. – KayV Apr 17 '16 at 07:55
  • I am directly running the project , by right clicking the project name and run on local tomcat server. After running the project this is the URL which is getting opened http://localhost:8088/Spring-practise-1/ Karan I have added the new folder structure picture – Prasad Madge Apr 17 '16 at 09:17
  • Then try `http://localhost:8080/`. If you still get the PageNotFound then I think there is something wrong with your Project structure. Try renaming `WebContent` folder to `webapp` because as per Maven Standards your `WEB-INF` should be under `src/main/webapp`. – Sanjay Rawat Apr 17 '16 at 11:16
  • I tried the [link] http://localhost:8080/ I was getting a Jenkins Page opened for that in Eclipse with server starting. I tried renamming it didnt worked. This is a spring related configuration issue , not sure why I am getting it , I am new to Spring MVC – Prasad Madge Apr 17 '16 at 12:08

0 Answers0