解决struts2中UI标签出现的问题: The Struts dispatcher cannot be found

时间:2023-03-08 20:36:26
解决struts2中UI标签出现的问题: The Struts dispatcher cannot be found

解决struts2中UI标签出现的问题: The Struts dispatcher cannot be found

异常信息:
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]

jsp中使用了struts的标签,如果这边只拦截action的话,那就会出现jsp中struts标签无法解析的情况,找不到struts的分发器dispatcher,这通常是由于使用了struts标签,而没有配置相关联的filter。struts标签只有在http请求通过标签的servlet filter过滤器之后才可用,这些过滤器用来为这些标签初始化struts分发器

解决办法:

1.引入
<%@ taglib prefix="s"  uri="/struts-tags" %>

2.在web.xml中未将拦截的*.action改成/*
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>

我当时出错就是第二种情况,是没有改WEB.XML中的拦截器