marioosh
marioosh

Reputation: 28556

MVC Controller and Web Flow Controller - Request handling priorities

I'm working with integration Spring Web Flow into Spring MVC web application.

I mapped Spring DispatcherServlet to *.html like below.

<servlet-mapping>
    <servlet-name>spring</servlet-name>
    <url-pattern>*.html</url-pattern>
</servlet-mapping>

I have registered simple flow (/WEB-INF/flows/simple/simple-flow.xml, /WEB-INF/flows/simple/simple.jsp) that gets simple id according to configuration.

<webflow:flow-registry id="flowRegistry" base-path="/WEB-INF/flows">
    <webflow:flow-location-pattern value="/**/*-flow.xml" />
</webflow:flow-registry>    

I mapped /simple.html (/WEB-INF/pages/simple.jsp) to my MVC Controller.

@Controller
public class SimpleController {

    @RequestMapping("/simple.html")
    public String simpleHandler(Model model) {
        return "simple";                    
    }
}

When i request simple.html, the SimpleController get that request, but when i remove mapping to that controller, simple.html leads to simple flow. I see that MVC controller have higher priority and get request before it reach flow controller. Of which is the result? How it works in that situation ? Can i change request handling order/priorities of ordinary MVC controllers and Web Flow controller ?

Upvotes: 2

Views: 4486

Answers (1)

marioosh
marioosh

Reputation: 28556

I've done it using order property. It is set to 0 by default and MVC controllers handling request before flow controller. I set order to -1 and now flow controller handle request before it reach my MVC controller. Is it good solution ?

<!-- Handle request after MVC controllers -->       
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
    <property name="flowRegistry" ref="flowRegistry"/>
    <property name="order" value="0"/>
</bean>

<!-- Handle request BEFORE MVC controllers -->      
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
    <property name="flowRegistry" ref="flowRegistry"/>
    <property name="order" value="-1"/>
</bean>

Upvotes: 7

Related Questions