新手学习Struts2问题- The Struts dispatcher cannot be found,求救啊,

song19830708 2011-10-24 09:48:12
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>


java 代码
import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport{

private String userName;
private String password;

public String getUserName() {
return userName;
}

public void setUserName(String userName) {
this.userName = userName;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}


public String execute() throws Exception{

return "success";
}

@Override
public void validate() {

if(this.getUserName() == null || "".equals(this.getUserName().trim())){
this.addFieldError("userName", "输入用户名");
}
if(this.getPassword() == null || "".equals(this.getPassword().trim())){
this.addFieldError("password", "输入密码");
}
}
}




struts.xml内容:
<package name="struts2" extends="struts-default">
<action name="login" class="com.scy.paylist.login.LoginAction">
<result name="success">/pay_list.jsp</result>
<result name="input">/login2.jsp</result>
</action>
</package>
...全文
1832 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
song19830708 2011-10-30
  • 打赏
  • 举报
回复
问题已经解决,换了个struts2版本就可以了。
kouyiSC 2011-10-28
  • 打赏
  • 举报
回复
应该是你的jsp页面引用标签没有找到。。。报的的是标签使用错误啊。。。
hfh891020 2011-10-28
  • 打赏
  • 举报
回复
如果想要在jsp文件中,采用 struts的tag,那么jsp必须是通过action跳转得到。你可以试着不在jsp里用struts标签,就用jsp的标签就行了。
song19830708 2011-10-28
  • 打赏
  • 举报
回复
是否和环境有关???
song19830708 2011-10-28
  • 打赏
  • 举报
回复
这个是错误
song19830708 2011-10-28
  • 打赏
  • 举报
回复
type Exception report

message

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.
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:372)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


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.login2_jsp._jspx_meth_s_form_0(login2_jsp.java:118)
org.apache.jsp.login2_jsp._jspService(login2_jsp.java:92)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.30 logs.

song19830708 2011-10-27
  • 打赏
  • 举报
回复
怎么没人回
song19830708 2011-10-27
  • 打赏
  • 举报
回复
自己顶一下啊
xiongyuanming 2011-10-27
  • 打赏
  • 举报
回复
你把那个 错误信息贴出来大家看看
song19830708 2011-10-25
  • 打赏
  • 举报
回复
我用的是struts-2.2.3.1在jsp页面上使用struts2标签后出错。没有使用struts2标签可以正常运行。。。。。
用了
javassist-3.11.0.GA.jar
commons-fileupload-1.2.2.jar
commons-logging-1.1.1.jar
freemarker-2.3.16.jar
ognl-3.0.1.jar
struts2-core-2.2.3.1.jar
xwork-core-2.2.3.1.jar
古市轩 2011-10-24
  • 打赏
  • 举报
回复
你在struts2-core-2.2.3.1.jar文件里查查FilterDispatcher这个类的包名,
我的是org.apache.struts2.dispatcher.ng.filter.FilterDispatcher
当然你得把需要的jar文件放到lib目录下咯!
Missing311 2011-10-24
  • 打赏
  • 举报
回复
你用的那个版本的struts2,不同的版本<filter-class> org.apache.struts2.dispatcher.FilterDispatcher </filter-class>中间的内容部太一样
错在葡萄 2011-10-24
  • 打赏
  • 举报
回复
你的代码我没找到错,可能是你的包引的不对,这个要看你的struts的版本了。如果是最新版的struts的话,你要在webContent的lib下放了类库了么?
放了哪些?加载的是哪些?
我以前少加了一个javassist-3.11.0.GA.jar就会有这个错。
要加的有:
javassist-3.11.0.GA.jar
commons-fileupload-1.2.2.jar
commons-io-2.0.1.jar
commons-lang-2.5.jar
commons-logging-1.1.1.jar
freemarker-2.3.16.jar
ognl-3.0.1.jar
spring-test-2.5.6.jar
struts2-core-2.2.3.1.jar
xwork-core-2.2.3.1.jar
song19830708 2011-10-24
  • 打赏
  • 举报
回复
jsp页面:

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'login2.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>

<body>
<s:form action="login">
<s:textfield name="userName" label="username"></s:textfield>
<s:password name="password" label="password"></s:password>
<s:submit label="submit"></s:submit>
</s:form >
</body>
</html>

81,094

社区成员

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

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