简体   繁体   中英

Spring MVC - HTTP Status 404 error. Anything missing in web.xml

My spring application is working on local machine properly. But, on deploying it on a VM, it is giving HTTP Status 404 error.

On VM:

http://serverIP:8080/Project/index.jsp

It is giving HTTP 404 error.

web.xml

<servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>*.htm</url-pattern>
</servlet-mapping>

<filter>
    <filter-name>osivf</filter-name>
    <filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>osivf</filter-name>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

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

dispatcher-servlet.xml

indexController

<bean id="viewResolver"
      class="org.springframework.web.servlet.view.InternalResourceViewResolver"
      p:prefix="/WEB-INF/jsp/"
      p:suffix=".jsp" />


<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
    <property name="maxUploadSize" value="10000000"/>
</bean>


<!--
The index controller.
-->
<bean name="indexController"
      class="org.springframework.web.servlet.mvc.ParameterizableViewController"
      p:viewName="index" />


<!--  <bean id="hibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate">
    <constructor-arg name="sessionFactory" ref="sessionFactory" />
</bean>-->

<!--<bean id="dao" class="food.db.DAO" />-->

Can somebody please help me here?

you are accessing the deployed application with in the VM than you donot need the VM ip , try with http://localhost:8080/Project/index.jsp

if you want to access the deployed application on vm from your local system, than you need to forward the port from vm to local system like

step 1. open the vm setting
Step 2. Go to the Network tab .
Step 3. In forwarded port need to define host port 8080 and guest port 8080
Step 4. start the VM.

http://<VM IP>:8080/Project/index.jsp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM