出现的错误如下:
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)
org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:48)
org.apache.jsp.Struts2Demo.WebRoot.index_jsp._jspx_meth_s_005ftext_005f0(index_jsp.java:104)
org.apache.jsp.Struts2Demo.WebRoot.index_jsp._jspService(index_jsp.java:71)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
我的Web.xml配置如下
<?xml version="1.0" encoding="GBK"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">

<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter> <filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
刚学习struts2不明白什么原因,请高手指点!

解决方案 »

  1.   

    The Struts dispatcher cannot be found. 这里的意思是说找不到合适的拦截器,去看下jar包
      

  2.   

    jar包问题
    FilterDispatcher </filter-class>有空格啊
      

  3.   

    先谢谢dongyang369
    可是要用到的包  我都放到WEB-INF/lib下了 就是不知道怎么找不到,网上找个很多 还是没解决。
      

  4.   

    warison2008
    在代码中没有空格,我也知道是jar的问题 可是怎么解决啊?
    请高手帮忙
      

  5.   

    访问的页面使用了struts标签,但是没有经过struts的过滤器。
      

  6.   

    jar包有问题么,重新下载一个嘛,这还用问???
      

  7.   

    我下载过两版本都有问题啊,应该不是这个问题
    warison2008
      

  8.   

    容器启动的时候报的错吗?如果是的话,没有相应的jar包放到classPath下
      

  9.   

    问题是怎么解决? 我也知道问题,你们用的什么strut2版本?
      

  10.   

    jsp上引入标签没有?
    贴处报错jsp页面来
      

  11.   

    错误的界面
    HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/struts2/views/jsp/TextTag
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    root cause javax.servlet.ServletException: java.lang.NoClassDefFoundError: org/apache/struts2/views/jsp/TextTag
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
    org.apache.jsp.Struts2Demo.WebRoot.index_jsp._jspService(index_jsp.java:87)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    root cause java.lang.NoClassDefFoundError: org/apache/struts2/views/jsp/TextTag
    org.apache.jsp.Struts2Demo.WebRoot.index_jsp._jspx_meth_s_005ftext_005f0(index_jsp.java:99)
    org.apache.jsp.Struts2Demo.WebRoot.index_jsp._jspService(index_jsp.java:71)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.
    --------------------------------------------------------------------------------Apache Tomcat/6.0.20
      

  12.   

    我还原了一下,错误页面如下:
    HTTP Status 500 - --------------------------------------------------------------------------------type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: 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.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    root cause 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)
    org.apache.struts2.views.jsp.ComponentTagSupport.doStartTag(ComponentTagSupport.java:48)
    org.apache.jsp.Struts2Demo.WebRoot.index_jsp._jspx_meth_s_005ftext_005f0(index_jsp.java:104)
    org.apache.jsp.Struts2Demo.WebRoot.index_jsp._jspService(index_jsp.java:71)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    note The full stack trace of the root cause is available in the Apache Tomcat/6.0.20 logs.
    --------------------------------------------------------------------------------Apache Tomcat/6.0.20
      

  13.   

    报错的页面是:
    <%@ page language="java" contentType="text/html; charset=UTF-8"%>
    <%@taglib prefix="s" uri="/struts-tags"%>
    <html>
    <head>
    <title><s:text name="loginPage"/></title>
    </head>
    <body>
    <s:form action="login">
                <s:textfield name="username" key="user"/>
                <s:textfield name="password" key="pass"/>
                <s:submit key="login"/>
    </s:form>
    </body>
    </html>
      

  14.   

    是web配置的问题,在struts2中不能直接使用jsp,引用struts2的标签
    加上这几行代码:
    <filter-mapping>   
        <filter-name>struts2</filter-name>   
        <url-pattern>*.jsp</url-pattern>   
    </filter-mapping> 
    <filter-mapping>   
        <filter-name>struts2</filter-name>   
        <url-pattern>/struts/*</url-pattern>   
    </filter-mapping>   
    </web-app>
    可以参考这篇文章:http://ajava.org/exep/ssh/17075.html
      

  15.   

    我也遇到这个问题了,结果是没有在web.xml里面配置过滤器,在web.xml里面添加下面一段代码:
    <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
      

  16.   

    解决此方法有三:
        一。所报错jsp页面中加入<%@taglib prefix="s" uri="/struts-tags"%>
        二. WEB.XML中 
    加上这几行代码:
    <filter-mapping>   
      <filter-name>struts2</filter-name>   
      <url-pattern>*.jsp</url-pattern>   
    </filter-mapping>  
    <filter-mapping>   
      <filter-name>struts2</filter-name>   
      <url-pattern>/struts/*</url-pattern>   
    </filter-mapping>特别是第三条,过滤器一定要这样写:  <filter>
    <filter-name>struts2</filter-name>
    <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
           <init-param>
             <param-name>config</param-name>
             <param-value>struts-default.xml,struts-plugin.xml,struts.xml</param-value>
            </init-param>
    </filter>