Search code examples
javaxmlspringspring-webflow

Java Spring: Trying to configure webflow by xml, can't find dispatcher-servlet.xml


I am just starting out trying to see what spring flow is about.This book that i have is describing how i have to configure the dispathcer-servlet.xml and create some flows in there.

Problem is i cannot find this dispatcher-servlet.xml file in my java spring application to start the configuration.Where is it?

I searched on here and on google but i only find people who already have n dispatcher-servlet.xml file and they are asking how to configure it.

Any help would be greatly appreciated!


Solution

  • You don't need dispatcher-servlet.xml to configure DispatcherServlet. It's just a default name Spring will look for if not defined. You can define config in contextConfigLocation init-param when defining DispatcherServlet in web.xml. Or, if you have single DispatcherServlet, you can use global spring xml configuration. If you have a working java spring application, look for

      <context-param>
        <param-name>contextConfigLocation</param-name>
    ...
      </context-param>
    

    or

      <servlet>
        <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    ...
      </servlet>
    
    

    in your web.xml

    If you don't find it in web.xml, you will have to configure it yourself. I also think that the book might be for webflow 1.x. Try using official Spring Webflow reference, it's a good starting point, and is up-to-date:

    https://docs.spring.io/spring-webflow/docs/current/reference/html/

    Specifically, for Dispatcher servlet configuration look at this chapter:

    https://docs.spring.io/spring-webflow/docs/current/reference/html/spring-mvc.html#spring-mvc-config-web.xml