Announcement Announcement Module
Collapse
No announcement yet.
AbstractController.handleRequestInternal not being called Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AbstractController.handleRequestInternal not being called

    Hello,

    I am trying to use spring mvc and I have run into a few problems.
    I am using spring-webmvc 2.5.2 and tomcat.

    I am following a simple spring-mvc example from the Spring in Action book.

    The problem I have is that the handleRequestInternal method in my page controller is not being called.
    The method is vey simple and is show below:

    Code:
    	
    
    protected ModelAndView handleRequestInternal(HttpServletRequest request,
    		                             HttpServletResponse response) throws Exception {
    		
        List<Rant> recentRants = getRantService().getRecentRants();	
        return new ModelAndView("home","rants", recentRants);
    }
    I suspect, but I'm not sure that because I am redirecting from my index.jsp page to my home page that I may be by-passing the spring DispatcherServlet.

    This is my index.jsp page

    HTML Code:
    <%@ page contentType="text/html; charset=UTF-8" %>
    <jsp:forward page="/WEB-INF/jsp/home.jsp" />
    I'm not sure if this is the problem or not, but I'm hoping that someone can point me in the right direction.

    Perhaps you can also tell me why when I change my servlet mapping from this:

    HTML Code:
    	<servlet-mapping>
    		<servlet-name>roadrantz</servlet-name>
    		<url-pattern>*.htm</url-pattern>
    	</servlet-mapping>
    to this:

    HTML Code:
    	<servlet-mapping>
    		<servlet-name>roadrantz</servlet-name>
    		<url-pattern>*.jsp</url-pattern>
    	</servlet-mapping>
    That nothing works. I find this strange because all my files end with .jsp

  • #2
    Put your web.xml and roadrantz.xml config here to see where is the problem

    Comment


    • #3
      web.xml

      HTML Code:
      <!DOCTYPE web-app PUBLIC
       "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
       "http://java.sun.com/dtd/web-app_2_3.dtd" >
      
      <web-app>
      	<display-name>Archetype Created Web Application</display-name>
      	<context-param>
      		<param-name>contextConfigLocation</param-name>
      		<param-value>/WEB-INF/roadrantz-data.xml /WEB-INF/roadrantz-service.xml</param-value>
      	</context-param>
      	<listener>
      		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      	</listener>	
      	<servlet>
      		<servlet-name>roadrantz</servlet-name>
      		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
      		<load-on-startup>1</load-on-startup>
      	</servlet>
      	<servlet-mapping>
      		<servlet-name>roadrantz</servlet-name>
      		<url-pattern>*.htm</url-pattern>
      	</servlet-mapping>
      </web-app>
      roadrantz-servlet.xml

      HTML Code:
      <?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:aop="http://www.springframework.org/schema/aop"
      	   xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                                 http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> 
      
      	<bean name="/home.htm" class="com.fujitsu.springmvc.controllers.HomePageController">
      		<property name="rantService" ref="rantService"/>
      	</bean>
      	
      	<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      		<property name="prefix">
      			<value>/WEB-INF/jsp</value>
      		</property>
      		<property name="suffix">
      			<value>.jsp</value>
      		</property>
      	</bean>
      	
      </beans>

      Comment


      • #4
        It's ok I figured this out.

        The problem was with my index.jsp page. You can see from below that I was redirecting to a jsp page.

        HTML Code:
        <%@ page contentType="text/html; charset=UTF-8" %>
        <jsp:forward page="/WEB-INF/jsp/home.jsp" />
        What I should have done was redirect to a /home.htm which is the name of my HomePageController bean. So I changed the above to:

        HTML Code:
        <%@ page contentType="text/html; charset=UTF-8" %>
        <jsp:forward page="/home.htm" />

        Comment

        Working...
        X