0

Im in a middle of a SpringMVC project and I have encountered a "no mapping found" error.

Here is my web.xml

<?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>Archetype Created Web Application</display-name>

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

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

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

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

dispatcher-servlet.xml :

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">


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

    <mvc:annotation-driven />

    <context:component-scan base-package="controller" />    


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

controller class:

package controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/EventZone/register/")
public class LoginController {

    @RequestMapping( method = RequestMethod.GET)
    public ModelAndView getRegisterPage(){

        ModelAndView model = new ModelAndView("RegisterViews/register");


        return model;
    }
}

Im trying every solution I can find but none seems to work.

lvi
  • 169
  • 1
  • 2
  • 8
  • What is the complete URL that you are trying to hit? Also include your webcontext. – minion Apr 06 '15 at 22:34
  • URL is http://localhost:8040/EventZone/register/ What do you mean by "include webcontext"? – lvi Apr 07 '15 at 06:14
  • Usually you will hit url of pattern `localhost:8040/{webcontext}/EventZone/register`. I see you are missing webcontext. What is your webcontext? – minion Apr 07 '15 at 12:52

1 Answers1

0

yes i.e what you were missing no need of extra logic you need to add wecontext means your application name like. http://localhost:8080/SpringMVN/EventZone/register/ tell me how you are deploying your application. and at last add the '/' you are missing that because you given at requestmapping in your controller class.

Sthogari
  • 45
  • 2
  • 14