Struts - 异常 - 找不到 Struts 调度程序
我正在使用 Struts 2.1.8.1
。我想在我的 jsp 页面中使用由 struts
提供的标签。例如
<%@ 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>
但是当我运行上面的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)
I am using Struts 2.1.8.1
. I want to use tags, supplied by struts
, im my jsp pages. e.g
<%@ 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:
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能将 Struts 2 标记与 Struts 1 一起使用。Struts 2 来自 WebWorks 项目,它不向后兼容 Struts 1。Struts
因此为什么你会得到这个:
获取 Struts 1 标记库并替换 Struts 2 标记库。
按照我对您问题的回答: Struts - Struts 提供的 .tld 的 JSP 页面中的 Taglib 指令
编辑 一个很好的教程站点:
You cannot use Struts 2 tags with Struts 1. Struts 2 is from the WebWorks project and it's not backward compatible with Struts 1.
Hence why you get this:
Get the Struts 1 taglibs and replace the Struts 2 taglibs.
Follow my answer from your question here: Struts - Taglib directive in a JSP page for .tld provided by Struts
Edit A good tutorial site: