eclipse - Maven springMVC project. page not loading showing error page not found -


i have created project maven in eclipse ide using springmvc. same project without maven running fine, after creating maven project not sure has gone wrong.
project when run on server shows error page not found.
codes as
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>loginmavenspringmvc</display-name>   <servlet>      <servlet-name>spring-dispatcher</servlet-name>      <servlet-class>          org.springframework.web.servlet.dispatcherservlet      </servlet-class>  </servlet>  <servlet-mapping>      <servlet-name>spring-dispatcher</servlet-name>      <url-pattern>/</url-pattern>  </servlet-mapping> </web-app> 

my dispatcher-servlet

<?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:p="http://www.springframework.org/schema/p"     xmlns:context="http://www.springframework.org/schema/context"     xmlns:mvc="http://www.springframework.org/schema/mvc"     xmlns:cache="http://www.springframework.org/schema/cache"     xsi:schemalocation="         http://www.springframework.org/schema/beans         http://www.springframework.org/schema/beans/spring-beans-3.0.xsd         http://www.springframework.org/schema/context         http://www.springframework.org/schema/context/spring-context-3.0.xsd         http://www.springframework.org/schema/mvc         http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd  http://www.springframework.org/schema/cache          http://www.springframework.org/schema/cache/spring-cache-3.2.xsd         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd">      <context:component-scan base-package="com.java.package.login"></context:component-scan>     <mvc:annotation-driven/>     <mvc:resources mapping="/resources/**" location="/resources/theme/" />      <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>    <mvc:resources mapping="/resources/**" location="/resources/theme/" />  </beans>   

my controller class

    package com.java.package.login;  import java.util.map;  import org.springframework.stereotype.controller; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.bind.annotation.requestmethod; import org.springframework.web.bind.annotation.requestparam; import org.springframework.web.servlet.modelandview;  @controller public class logincontroller {      @requestmapping(value="/login.html", method=requestmethod.get)      public modelandview getloginform(){         modelandview model = new modelandview("login");         system.out.println("working");         return model;      } }   

my project structure
enter image description here

where wrong.. when run on server says page not found.

you missing below spring-dispatcher in web.xml.

    <listener>         <listener-class>org.springframework.web.context.contextloaderlistener</listener-class>     </listener>      <init-param>         <param-name>contextconfiglocation</param-name>         <param-value>             classpath:location_of_your_spring_conf_xml             eg: /web-inf/spring/web-rest-config.xml                      </param-value>     </init-param>         <load-on-startup>1</load-on-startup> 

Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -