The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the associated filter.

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

环境:tomcat5.5.0

struts.xml信息

<?xml version="1.0" encoding="UTF-8"?> 
<web-app version="2.4"  
    xmlns="http://java.sun.com/xml/ns/j2ee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
  <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>*.action</url-pattern> 
  </filter-mapping> 
  <welcome-file-list> 
    <welcome-file>index.jsp</welcome-file> 
  </welcome-file-list> 
</web-app> 
         struts.xml 信息:

<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd"
<struts> 
  <include file="struts-default.xml"/> 
  <package name="ygn.action" extends="struts-default"> 
    <action name="HelloWorld" class="ygn.action.HelloWorld"> 
      <result>HelloWorld.jsp</result> 
    </action> 
  </package> 
</struts> 
       SayHello.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%> 
<%@ taglib prefix="s" 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=UTF-8"> 
<title>Say Hello</title> 
</head> 
<body> 
  <h3>Say "Hello" to :</h3> 
  <s:form action="HelloWorld"> 
    Name:<s:textfield name="name"/> 
    <s:submit/> 
  </s:form> 
</body> 
</html>

异常分析:以上的配置及文件中,如果采用 http://ip:port/SayHello.jsp,那么会出现前面所提到的异常。如果采用http://ip:port/SayHello.action 进行访问,那么正常。

原因:如果想要在jsp文件中,采用 struts的tag,那么必须通过web.xml所配置的过滤器访问文件,否则会有异常,即 之前所出现的异常。

解决方案:

方案一:

采用 http://ip:port/SayHello.action 访问

方案二:

将web.xml 的过滤器,从 *.action 修改为: /*

方案三:

修改SayHello.jsp 文件,不使用 struts 的标签。

最新文章

  1. 6.在MVC中使用泛型仓储模式和依赖注入实现增删查改
  2. # git 操作拾遗
  3. MySQL删除/更新数据时报1175错误
  4. LeetCode Shell Problems
  5. 编译gd-2.0.35.tar.gz时报错:gd_png.c:16:53: error: png.h: No such file or directory
  6. IPython学习笔记
  7. nginx 正则表达式
  8. POI导出excel并下载(以流的形式在客户端下载,不保存文件在服务器上)
  9. react源码总览(翻译)
  10. [Android] Android 类似今日头条顶部的TabLayout 滑动标签栏 效果
  11. 解决npm ERR! Please try running this command again as root/Administrator. 问题
  12. 刘志梅2017710101152.《面向对象程序设计(java)》第十三周学习总结
  13. BZOJ1786 [Ahoi2008]Pair 配对 动态规划 逆序对
  14. L1正则和L2正则的比较分析详解
  15. Linq EF 添加数据执行事务处理
  16. python中的迭代器和生成器学习笔记总结
  17. vue watch监控对象
  18. 《剑指Offer》题六十一~题六十八
  19. Android 之Navicat for SQLite 数据库介绍
  20. 【Linux】查看磁盘空间大小

热门文章

  1. 读取xml文件内容到数据库
  2. [Flex] FlashBuilder 4.6运用标签嵌入字体方法
  3. 从零开始完整搭建 Spring-Boot 项目开发框架的教程
  4. 阿里云服务主机部署Thinkphp系统错误解决方案
  5. [HDU4089]Activation(概率DP)
  6. HTML 标记大全参考手册
  7. DOM操作 045
  8. oracle模糊查询提高效率的方法
  9. ionic3打包打包安卓apk详细过程以及遇到的问题
  10. 3dsmax2018卸载/安装失败/如何彻底卸载清除干净3dsmax2018注册表和文件的方法