英文:
Java Spring: Trying to configure webflow by xml, can't find dispatcher-servlet.xml
问题
我刚刚开始尝试了解Spring Flow是什么。我有一本书,它描述了我如何配置dispatcher-servlet.xml并在其中创建一些流程。
问题是我找不到这个dispatcher-servlet.xml文件在我的Java Spring应用程序中,以开始配置。它在哪里?
我在这里和谷歌上搜索了,但我只找到那些已经有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!
答案1
得分: 1
你不需要 dispatcher-servlet.xml 来配置 DispatcherServlet。如果未定义,默认情况下 Spring 会查找这个名称。你可以在 web.xml 中定义 DispatcherServlet 时,在 contextConfigLocation 初始化参数中定义配置。或者,如果只有一个 DispatcherServlet,可以使用全局的 Spring XML 配置。如果你有一个正在运行的 Java Spring 应用程序,请查找以下内容:
<context-param>
<param-name>contextConfigLocation</param-name>
...
</context-param>
或者
<servlet>
<servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
...
</servlet>
在你的 web.xml 中。如果在 web.xml 中找不到它,你将需要自己进行配置。我还认为这本书可能是针对 webflow 1.x 的。尝试使用官方的 Spring Webflow 参考文档,这是一个很好的起点,并且是最新的:
https://docs.spring.io/spring-webflow/docs/current/reference/html/
特别是,对于 Dispatcher servlet 配置,请参阅这一章节:
英文:
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:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论