gpt4 book ai didi

java - Struts - 异常 - 找不到 Struts 调度程序

转载 作者:行者123 更新时间:2023-11-29 08:18:32 26 4
gpt4 key购买 nike

我正在使用 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)

最佳答案

不能在 Struts 1 中使用 Struts 2 标签。Struts 2 来自 WebWorks 项目,它不向后兼容 Struts 1。

  • Struts 1 使用 Actions
  • Struts 2 使用过滤器和调度程序。

因此你得到这个的原因:

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 1 标签库并替换 Struts 2 标签库。

在这里按照我的问题回答:Struts - Taglib directive in a JSP page for .tld provided by Struts

编辑 一个很好的教程网站:

关于java - Struts - 异常 - 找不到 Struts 调度程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2395364/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com