Announcement Announcement Module
Collapse
No announcement yet.
Spring Webflow and Spring MVC config issue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Webflow and Spring MVC config issue

    I have been using webflow for a while and now want to add spring mvc to the mix. I can get to my flows, but I can't get to any of my annotated controllers. Here's how it is currently configured:

    Code:
    ...
    	<bean id="flowController" class="org.springframework.webflow.mvc.servlet.FlowController">
    	    <property name="flowExecutor" ref="flowExecutor"/>
    	    <property name="flowHandlerAdapter" ref="customFlowHandlerAdapter" />
    	    <property name="flowUrlHandler">
    	        <bean class="org.springframework.webflow.context.servlet.WebFlow1FlowUrlHandler"/>
    	    </property>
    	</bean>
    	
    	<bean id="customFlowHandlerAdapter" class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
    		<property name="flowExecutor" ref="flowExecutor"/>
    		<property name="flowExecutor.executionRepository.alwaysGenerateNewNextKey" value="false"/>
    	</bean>
    	
    	
    	<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>
    	<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    		<property name="mappings">
    	        <value>
    		    	/iv.xval=flowController
    			</value>
    	   </property>
    	   <property name="order" value="0" />
    	</bean>
    
    	<!-- Maps requests to @Controllers based on @RequestMapping("path") annotation values
    		 If no annotation-based path mapping is found, Spring MVC proceeds to the next HandlerMapping (order=2 below). -->
    	<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
    		<property name="order" value="1" />
    	</bean>
    	
    	<!-- Maps requests to @Controllers based on controller class name convention; e.g. a request for /hotels or a /hotels sub-resource maps to HotelsController
    	     If no class mapping is found, Spring MVC sends a 404 response and logs a pageNotFound warning. -->
    	<bean class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
    		<property name="order" value="2" />
    	</bean>
    	
    	
    	<!-- Enables annotated @Controllers; responsible for invoking an annotated POJO @Controller when one is mapped. -->
    	<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
        <context:component-scan base-package="com.xactsites.xacttotal.valuation.web" />
    ...
    Here's my controller:

    Code:
    @Controller
    @RequestMapping("/mmNada.test")
    public class MmNadaController
    {
    	public MmNadaController()
    	{
    		super();
    	}
    	
    	@RequestMapping(value="/", method = RequestMethod.GET)
    	public void defaultPage()       
    	{      
    		Log.trace("test");
    	}  
    	
    }
    My web.xml servlet mapping looks like this:
    Code:
    <servlet>
    	<servlet-name>iv</servlet-name>
    	<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    	<init-param>
    		<param-name>contextConfigLocation</param-name>
    		<param-value>
    			/WEB-INF/iv-webflow-config.xml
    		</param-value>
    	</init-param>
    	<load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    	<servlet-name>iv</servlet-name>
    	<url-pattern>*.xval</url-pattern>
    </servlet-mapping>
    When I go to the following url on my machine: http://localhost:8080/apps/iv/iv.xva...Id=mytest-flow it works great. However if I try to go to this url: http://localhost:8080/apps/iv/mmNada.test it doesn't get to my Log.trace("test");. It gets a 404 error, I even tried going to http://localhost:8080/apps/iv/mmNada/ to see if it would pick up the controller class name. I am guessing this is just a simple setup issue, but I can't seem to figure this out. Any direction would be greatly appreciatted. Thanks.

  • #2
    Ok, I spent hours trying to figure this out before posting it and now, soon after I do I found out what was going on. My web.xml was only looking for the pattern *.xval, thus excluding my controllers from getting called because the request wasn't routed through the dispatchServlet.

    Comment

    Working...
    X