The Struts dispatcher cannot be found. This is usually caused by using Struts tags without the asso
2016-04-27 01:02
525 查看
异常信息: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.
环境:tomcat 6.0 struts2.21
web.xml的配置:
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
默认是进行.action的过滤,以前都是使用freemarker作为显示端的,没出错,现在用jsp来显示点东西却出现了这个错误
Test.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>测试</title>
</head>
<body>
<s:form action = "testAction.action">
<s:textfield name = "stuMap['one'].stuNum" label = "第一个用户名"/>
<s:password name = "stuMap['one'].password" label = "第一个密码"></s:password>
<s:textfield name = "stuMap['two'].stuNum" label = "第二个用户名"/>
<s:password name = "stuMap['two'].password" label = "第二个密码"></s:password>
<s:submit name = "send" value = "提交" theme = "simple"></s:submit>
</s:form>
</body>
</html>
struts2的标签已经引入了,查询后归纳了以下几种方法:
1.将web.xml下的struts2过滤器的过滤方式从.action改为/*; 不过这种方式自己感觉不太好,应该这样默认就将所有的进行了过滤,可能会对有些应用带来麻烦,例如
fck的配置
2. 修改Test.jsp 文件,不使用 struts 的标签
3.就是在web.xml配置文件中再添加一个filter:
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
Struts tags are only usable when the request has passed through its servlet filter,
which initializes the Struts dispatcher needed for this tag.
环境:tomcat 6.0 struts2.21
web.xml的配置:
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
默认是进行.action的过滤,以前都是使用freemarker作为显示端的,没出错,现在用jsp来显示点东西却出现了这个错误
Test.jsp:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>测试</title>
</head>
<body>
<s:form action = "testAction.action">
<s:textfield name = "stuMap['one'].stuNum" label = "第一个用户名"/>
<s:password name = "stuMap['one'].password" label = "第一个密码"></s:password>
<s:textfield name = "stuMap['two'].stuNum" label = "第二个用户名"/>
<s:password name = "stuMap['two'].password" label = "第二个密码"></s:password>
<s:submit name = "send" value = "提交" theme = "simple"></s:submit>
</s:form>
</body>
</html>
struts2的标签已经引入了,查询后归纳了以下几种方法:
1.将web.xml下的struts2过滤器的过滤方式从.action改为/*; 不过这种方式自己感觉不太好,应该这样默认就将所有的进行了过滤,可能会对有些应用带来麻烦,例如
fck的配置
2. 修改Test.jsp 文件,不使用 struts 的标签
3.就是在web.xml配置文件中再添加一个filter:
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.jsp</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
相关文章推荐
- eclipse启动动画自动消失并且没有反应开启失败的解决方法
- JavaWeb之Servlet day01
- Java native 本地方法调用
- Smali反编译Java文件
- spring+springmc+mybatis整合遇见的问题
- java web笔记——服务器端防刷新页面重复提交表单
- 【转】Java线程安全和非线程安全
- Java单例模式
- Caused by: java.lang.SecurityException: Jurisdiction policy files are not signed by trusted sign...
- Spring事务配置的五种方式
- org.springframework.web.SpringServletContainerInitializer cannot be cast to javax.servlet.Servle...
- 通过三目运算符来看JAVA的自动拆箱和装箱
- Spring Boot 入门
- Java在WEB项目中获取文件路径
- java 日期格式 毫秒
- Java Date Compare 日期比较
- JAVA单例模式
- java通过JDBC_获取数据库连接
- 解决Eclipse 启动后总是Building WorkSpace(sleeping)
- SpringMvc与Struts2的对比,孰优孰劣