Pergunta

My app is deployed properly but getting 404 error. Unable to find what is happening. In this deployed means pointing my webapp folder to location in computer.

URL used :

localhost:8080/studentspringmvc/

web.xml

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

 <display-name>Spring MVC Application</display-name>

 <context-param>
     <param-name>contextConfigLocations</param-name>
     <param-value>classpath*:applicationContext.xml</param-value>
 </context-param>


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

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

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

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
</welcome-file-list>

</web-app>

Now I have added studentspringmvc.xml in conf/Catalina/localhost folder as

studentspringmvc.xml

<Context path="/studentspringmvc"
  docBase="/home/shoaib/Documents/myprograms/studentspringmvc/src/main/webapp" 
 reloadable="true" 
/>

Unable to find why atleast index.html is not loading. enter image description here enter image description here

Foi útil?

Solução

Your dispatcher servlet is mapped to /. This means that every URL is mapped to this servlet (index.html included). To make sure static files are still served, you need to enable the default servlet handler as explained in the documentation:

<mvc:default-servlet-handler/>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top