java Struts - 异常 - 无法找到 Struts 调度程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2395364/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Struts - Exception - The Struts dispatcher cannot be found
提问by Yatendra Goel
I am using Struts 2.1.8.1. I want to use tags, supplied by struts, im my jsp pages. e.g
我正在使用Struts 2.1.8.1. 我想使用由struts, im 我的 jsp 页面提供的标签。例如
<%@ taglib prefix="html" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Transfer Program - Login</title>
</head>
<body>
<html:form action="/loginaction.do" method="post">
Username:<html:text name="username"></html:text>
</html:form>
</body>
</html>
But when I run the above jsp page, I got the following error:
但是当我运行上面的jsp页面时,出现以下错误:
The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]
org.apache.struts2.views.jsp.TagUtils.getStack(TagUtils.java:60)
org.apache.struts2.views.jsp.StrutsBodyTagSupport.getStack(StrutsBodyTagSupport.java:44)
回答by Buhake Sindi
You cannotuse Struts 2 tags with Struts 1. Struts 2 is from the WebWorks project and it's not backward compatible with Struts 1.
您不能在 Struts 1 中使用 Struts 2 标签。Struts 2 来自 WebWorks 项目,它不向后兼容 Struts 1。
- Struts 1 works with Actions
- Struts 2 works with filters and dispatchers.
- Struts 1 与动作一起工作
- Struts 2 与过滤器和调度器一起工作。
Hence why you get this:
因此,为什么你会得到这个:
The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter. Struts tags are only usable when the request has passed through its servlet filter, which initializes the Struts dispatcher needed for this tag. - [unknown location]
找不到 Struts 调度程序。这通常是由于使用没有关联过滤器的 Struts 标签造成的。Struts 标签仅在请求通过其 servlet 过滤器时可用,该过滤器初始化此标签所需的 Struts 调度程序。- [未知地点]
Get the Struts 1 taglibs and replace the Struts 2 taglibs.
获取 Struts 1 标记库并替换 Struts 2 标记库。
Follow my answer from your question here: Struts - Taglib directive in a JSP page for .tld provided by Struts
按照我在此处回答您的问题:Struts - Struts 提供的 .tld 的 JSP 页面中的 Taglib 指令
EditA good tutorial site:
编辑一个好的教程网站:
- http://wiki.apache.org/struts/StrutsTutorials
- http://www.roseindia.net/struts/. Here it explains what Actions, Plugins, Tags, Validation, mappings, etc. works and how to use them. Read on Struts 1and not Struts 2.
- http://wiki.apache.org/struts/StrutsTutorials
- http://www.roseindia.net/struts/。这里解释了操作、插件、标签、验证、映射等的工作原理以及如何使用它们。阅读Struts 1而不是 Struts 2。

