简体   繁体   中英

Struts - Exception - The Struts dispatcher cannot be found

I am using Struts 2.1.8.1 . I want to use tags, supplied by struts , im my jsp pages. eg

<%@ 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>

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)

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.

  • Struts 1 works with Actions
  • Struts 2 works with filters and dispatchers.

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]

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:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM