title: Tomcat web page does not open with Spring Framework
body: <p>I add spring-5.2.9.RELEASE-dist as a library(lib). But I could'nt open index.jsp file that includes just html Hello World message.How could I fix what following error?</p>
  <p>HTTP Status 404 – Not Found<br>
  Description : The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.</p>
  <pre><code>package com.aaa.aaa;
  
  import org.springframework.stereotype.Component;
  import org.springframework.web.bind.annotation.RequestMapping;
  
  import javax.servlet.http.HttpServlet;
  
  @Component
  public class MyServlet extends HttpServlet {
  
      @RequestMapping(&quot;/aaa&quot;)
      public String showPage(){
          return &quot;index&quot;;
      }
  }
  </code></pre>
  <p>MyServlet.java</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;web-app xmlns=&quot;http://xmlns.jcp.org/xml/ns/javaee&quot;
           xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
           xsi:schemaLocation=&quot;http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd&quot;
           version=&quot;4.0&quot;&gt;
      &lt;display-name&gt;secondApp&lt;/display-name&gt;
  
      &lt;absolute-ordering /&gt;
  
      &lt;!-- Spring MVC Configs --&gt;
  
      &lt;!-- Step 1: Configure Spring MVC Dispatcher Servlet --&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;/WEB-INF/spring-mvc-demo-servlet.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;
  
      &lt;!-- Step 2: Set up URL mapping for Spring MVC Dispatcher Servlet --&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  <p>web.xml</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
      xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; 
      xmlns:context=&quot;http://www.springframework.org/schema/context&quot;
      xmlns:mvc=&quot;http://www.springframework.org/schema/mvc&quot;
      xsi:schemaLocation=&quot;
          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.xsd
          http://www.springframework.org/schema/mvc
          http://www.springframework.org/schema/mvc/spring-mvc.xsd&quot;&gt;
  
      &lt;!-- Step 3: Add support for component scanning --&gt;
      &lt;context:component-scan base-package=&quot;com.aaa.aaa&quot; /&gt;
  
      &lt;!-- Step 4: Add support for conversion, formatting and validation support --&gt;
      &lt;mvc:annotation-driven/&gt;
  
      &lt;!-- Step 5: Define Spring MVC view resolver --&gt;
      &lt;bean
          class=&quot;org.springframework.web.servlet.view.InternalResourceViewResolver&quot;&gt;
          &lt;property name=&quot;prefix&quot; value=&quot;/WEB-INF/view/&quot; /&gt;
          &lt;property name=&quot;suffix&quot; value=&quot;.jsp&quot; /&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  <p>spring-mvc-demo-servlet.xml
  <br><a href="https://i.stack.imgur.com/TFLQ5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TFLQ5.png" alt="Project" /></a></p>
  <p><a href="https://i.stack.imgur.com/v8T8C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v8T8C.png" alt="Tomcat Configuration" /></a></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  </code></pre>
  <p>
  4.0.0</p>
  <pre><code>&lt;groupId&gt;com.example&lt;/groupId&gt;
  &lt;artifactId&gt;secondApp&lt;/artifactId&gt;
  &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
  &lt;name&gt;secondApp&lt;/name&gt;
  &lt;packaging&gt;war&lt;/packaging&gt;
  
  &lt;properties&gt;
      &lt;maven.compiler.target&gt;1.8&lt;/maven.compiler.target&gt;
      &lt;maven.compiler.source&gt;1.8&lt;/maven.compiler.source&gt;
      &lt;junit.version&gt;5.6.2&lt;/junit.version&gt;
  &lt;/properties&gt;
  
  &lt;dependencies&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;javax&lt;/groupId&gt;
          &lt;artifactId&gt;javaee-web-api&lt;/artifactId&gt;
          &lt;version&gt;8.0.1&lt;/version&gt;
          &lt;scope&gt;provided&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;
          &lt;artifactId&gt;junit-jupiter-api&lt;/artifactId&gt;
          &lt;version&gt;${junit.version}&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.junit.jupiter&lt;/groupId&gt;
          &lt;artifactId&gt;junit-jupiter-engine&lt;/artifactId&gt;
          &lt;version&gt;${junit.version}&lt;/version&gt;
          &lt;scope&gt;test&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
          &lt;version&gt;5.2.9.RELEASE&lt;/version&gt;
          &lt;scope&gt;compile&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
          &lt;version&gt;5.2.9.RELEASE&lt;/version&gt;
          &lt;scope&gt;compile&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
          &lt;version&gt;5.2.9.RELEASE&lt;/version&gt;
          &lt;scope&gt;compile&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
          &lt;version&gt;5.2.9.RELEASE&lt;/version&gt;
          &lt;scope&gt;compile&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-expression&lt;/artifactId&gt;
          &lt;version&gt;5.2.9.RELEASE&lt;/version&gt;
          &lt;scope&gt;compile&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
          &lt;version&gt;5.2.9.RELEASE&lt;/version&gt;
          &lt;scope&gt;compile&lt;/scope&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.springframework&lt;/groupId&gt;
          &lt;artifactId&gt;spring-webmvc&lt;/artifactId&gt;
          &lt;version&gt;5.2.9.RELEASE&lt;/version&gt;
      &lt;/dependency&gt;
  &lt;/dependencies&gt;
  
  &lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-war-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.3.0&lt;/version&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
  </code></pre>
  
  <p>pom.xml</p>