Spring-MVC adds an extra .jsp extension to the url where the user enters
The error message I receive is the description The requested resource (/gradebook/WEB-INF/jsp/hello.jsp.jsp) is not available
. I have a directory WEB-INF/jsp
that contains hello.jsp
Spring seems to add a jsp extension and I cannot figure out why. I have pasted web.xml
and 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">
<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>
source to share
Spring adds ".jsp" because you told it it InternalResourceViewResolver
was configured to add the .jsp suffix to whatever view name your controller returns.
I am assuming your class is HelloController
returning "hello.jsp" from a handler method? It should just return "hello" and Spring will add ".jsp" as you configured it.
source to share