Java Spring: 尝试通过xml配置webflow,找不到dispatcher-servlet.xml

huangapple go评论76阅读模式
英文:

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 配置,请参阅这一章节:

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

英文:

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

  &lt;context-param&gt;
    &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
...
  &lt;/context-param&gt;

or

  &lt;servlet&gt;
    &lt;servlet-name&gt;Spring MVC Dispatcher Servlet&lt;/servlet-name&gt;
    &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
...
  &lt;/servlet&gt;

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

huangapple
  • 本文由 发表于 2020年8月5日 04:14:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/63254427.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定