java - servlet mapping always 404 error -


this web.xml file

<!doctype web-app public  "-//sun microsystems, inc.//dtd web application 2.3//en"  "http://java.sun.com/dtd/web-app_2_3.dtd" >  <web-app>   <display-name>archetype created web application</display-name>    <context-param>     <param-name>contextconfiglocation</param-name>     <param-value>/web-inf/applicationcontext.xml</param-value>   </context-param>    <servlet>     <servlet-name>myservlet</servlet-name>     <servlet-class>org.springframework.web.servlet.dispatcherservlet</servlet-class>     <init-param>        <param-name>contextconfiglocation</param-name>        <param-value>/web-inf/applicationcontext.xml</param-value>     </init-param>     <load-on-startup>1</load-on-startup>   </servlet>    <servlet-mapping>     <servlet-name>myservlet</servlet-name>     <url-pattern>*.html</url-pattern>   </servlet-mapping> </web-ap> 

applicationcontext.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/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.3.xsd         http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd">           <context:component-scan base-package="com.tutorial.ejemplospring" />          <bean             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> 

and controller

package com.tutorial.ejemplospring;  import org.springframework.stereotype.controller; import org.springframework.web.bind.annotation.requestmapping; import org.springframework.web.servlet.modelandview;  @controller public class maincontroller {      @requestmapping("/main.html")     public modelandview mainpage() {          return new modelandview("main");     }  } 

i don't know why ´http:localhost:8080/ejemplospring/mail.html´ doesn't match url pattern .html?, 404 error , if try / or / same error.

try uncomment

<context:component-scan base-package="com.tutorial.ejemplospring" /> 

seems not finding controller , therefore not registering mapping.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -