views:

275

answers:

1

The error message I get is description The requested resource (/gradebook/WEB-INF/jsp/hello.jsp.jsp) is not available. I have a WEB-INF/jsp directory that contains hello.jsp Spring appears to be adding the jsp extension and I can't figure out why. I've pasted my web.xml and my gradebook-servlet.xml below.

<?xml version="1.0" encoding="UTF-8"?>

<web-app version="2.4"
         xmlns="http://java.sun.com/xml/ns/j2ee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
         http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" >
  <servlet>
    <servlet-name>gradebook</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

  <servlet-mapping>
    <servlet-name>gradebook</servlet-name>
    <url-pattern>*.htm</url-pattern>
  </servlet-mapping>
  <welcome-file-list>
    <welcome-file>
      *index.jsp*
    </welcome-file>
  </welcome-file-list>
</web-app>


<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"&gt;
  <bean name="/hello.htm" class="gradebook.web.HelloController"/>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass">
        <value>org.springframework.web.servlet.view.JstlView</value>
        </property>
    <property name="prefix">
        <value>/WEB-INF/jsp/</value>
    </property>
    <property name="suffix">
        <value>.jsp</value>
    </property>
</bean>
</beans>
+2  A: 

Spring is adding ".jsp" because you've told it to - the InternalResourceViewResolver has been configured to add the ".jsp" suffix to whatever view name your controller returns.

I'm guessing your HelloController class is returning "hello.jsp" from its handler method? It should just be returning "hello", and Spring will append the ".jsp" as you've configured it.

skaffman
Thanks, I was returning hello.jsp changing it to hello fixed the problem.
Jared