bircastri
bircastri

Reputation: 2161

Tomcat not find the index.jsp when it starting

I have a J2ee application with spring. I have apply some modify at the page but now, when I try to start the server, I have this:

enter image description here

This is the application-servlet.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:p="http://www.springframework.org/schema/p"
    xmlns:context="http://www.springframework.org/schema/context"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">

     <bean id="lo4gjConfigurator" class="com.springmvcapp.log.LoggerFactory">
       <property name="logReInit">
        <value>true</value>
       </property>  
       <property name="fileName">
        <value>log4j.xml</value>
       </property> 
    </bean>

    <context:component-scan base-package="com.springmvcapp.controller" />

    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="viewClass"
            value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/WEB-INF/jsp/" />
        <property name="suffix" value=".jsp" />
    </bean>

    <bean id="simpleUrlMapping" class="com.springmvcapp.security.AccessDecisionUrlMapping">
        <property name="alwaysUseFullPath" value="true" />
        <property name="mappings">
            <props>
                <prop key="/index.html">homeController</prop>
                <prop key="/registrazione.html">registrazioneController</prop>
            </props>
        </property>
    </bean>

    <bean id="homeController" class="com.springmvcapp.controller.HelloWorld">
        <property name="methodNameResolver">
            <bean
                class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
                <property name="defaultMethodName">
                    <value>loadPage</value>
                </property>
                <property name="paramName">
                    <value>method</value>
                </property>
            </bean>
        </property> 
    </bean>

    <bean id="registrazioneController" class="com.springmvcapp.controller.RegistrazioneController">
        <property name="methodNameResolver">
            <bean
                class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
                <property name="defaultMethodName">
                    <value>loadPage</value>
                </property>
                <property name="paramName">
                    <value>method</value>
                </property>
            </bean>
        </property> 
    </bean>


</beans>

This is the web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app 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"
id="WebApp_ID" version="2.5">
  <display-name>SpringMVCApp</display-name>
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <servlet-name>springmvcapp</servlet-name>
    <servlet-class>
            org.springframework.web.servlet.DispatcherServlet
        </servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>springmvcapp</servlet-name>
    <url-pattern>*.html</url-pattern>
  </servlet-mapping>
</web-app>

This is the jsp file:

enter image description here

I don't know why the tomcat don't find the index.jsp.

Upvotes: 1

Views: 1778

Answers (2)

Alok kumar
Alok kumar

Reputation: 9

You have to keep you index.jsp file in public folder i.e. WebContent folder for direct access.

Upvotes: 0

Stefan
Stefan

Reputation: 12453

Your index.jsp is located in directory "WEB-INF" which cannot be accessed by url. Move it to the root of your application.

Another option is to redirect the first call to a spring controller. Create an index.html for example and add a redirect to it, i.E.:

<meta http-equiv="refresh" content="0; url=/app/">

Upvotes: 2

Related Questions