0

I'm working on the Spring MVC "FitnessTracker" application outlined on Pluralsight. Below is my "web.xml" file:

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5"
         xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                            http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

  <servlet>
    <servlet-name>fitTrackerServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/config/servlet-config.xml</param-value>
    </init-param>
  </servlet>

  <servlet-mapping>
    <servlet-name>fitTrackerServlet</servlet-name>
    <url-pattern>/FitnessTracker/*.html</url-pattern>
  </servlet-mapping>

  <display-name>Archetype Created Web Application</display-name>
</web-app>

The above makes Tomcat generate a bunch of exceptions, starting with

org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[]]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:153)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:899)

But when I change what's between the <url-pattern> tag to *.html, it works fine. Why is that?

Note: My goal is to try to make my app's controller run when I type /FitnessTracker/greeting.html, instead of /greeting.html. I am using Intellij IDEA, and doing Maven project with Tomcat 7.0 as my server.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Enis
  • 171
  • 9

2 Answers2

1

Application runs @ http://localhost:9090/FitnessTracker/greeting.html URL . FitnessTracker is application root context and greeting.html is mapped to Hello controller method. Please see below.

enter image description here

Could you please post the web.xml and controller mapping .

Mahesh Biradar
  • 351
  • 2
  • 9
1

The original code runs at the URL - http://localhost:8080/FitnessTracker/greeting.html. SO I am not sure why you need to change web.xml for that.

Also the URL pattern you are trying to use "/FitnessTracker/*.html" is not valid. More details here. https://stackoverflow.com/a/5441862/6352160

Community
  • 1
  • 1
Shankar
  • 2,625
  • 3
  • 25
  • 49