求助!!!The Struts dispatcher cannot be found. 错误

a707903908 2011-11-26 03:18:27
我的struts2版本是:2.2.3.1
我加了struts2的那五个包
我加了过滤器
<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>
为什么我的jsp运行就404错误。
但是当我没有加入任何过滤器的时候,myeclipse自带的测试jsp文件(index.jsp)却可以正常显示!
只要一加任何过滤器就直接404错误!如下:
type Status report

message

description The requested resource () is not available.
我搞不懂为什么总是错,请各位帮忙看下!
本人的分不多了、请见谅……

...全文
154 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
半个鼠标 2011-11-26
  • 打赏
  • 举报
回复
试试两个地方,首先是你的filter已经过时了,老版的,建议用新的!楼上说了
还有你进入action的方式错误了,你可能是.action或者.do,可能myeclipse可以生成,但是工具是用错误的
我建议你自己写个
在你的struts.xml中的第一个packge上面加入这样一句
<constant name="struts.action.extension" value="do,action"></constant>
这句话表示,你在跳转的时候可以.do或者.action进入action



<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN" "http://struts.apache.org/dtds/struts-2.1.dtd">
<struts>

<constant name="struts.action.extension" value="do,action,in"></constant>
<package name="it" namespace="/test" extends="struts-default">
<action name="te" class="com.test.IndexAction" method="execute">
<result name="success">/message.jsp</result>
</action>
</package>
</struts>

这是个例子,如果你想要条到IndexAction里面 应该是这样的http://127.0.0.1:8080/项目名/test/te.do
这是试试了
jiangc1987 2011-11-26
  • 打赏
  • 举报
回复
顺便建议下你使用org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
这个filter,
jiangc1987 2011-11-26
  • 打赏
  • 举报
回复
看看 tomcat日志吧, 你的工程没有启动成功, 应该是你的struts那里没有配置正确

81,115

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧