这是个关于struts2的问题...其他配置正确...到底哪里出错了......
配置文件-----<?xmlversion="1.0"encoding="UTF-8"?><!DOCTYPEstrutsPUBLIC"-//ApacheSoftwareF...
配置文件 -----
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="itcast" extends="struts-default">
<interceptors>
<interceptor name="myInterceptor" class="my.bag.interceptor.ActionInterceptor"/>
<interceptor-stack name="InterceptorStack">
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="myInterceptor"/>
</interceptor-stack>
</interceptors>
<global-results>
<result name="succeed">/verfy.jsp</result>
</global-results>
<action name="myActionDemo01" class="my.bag.action.myAction">
<interceptor-ref name="InterceptorStack"/>
</action>
</package>
</struts>
Action类
package my.bag.interceptor;
import com.opensymphony.xwork2.ActionSupport;
public class myAction {
public String execute(){
return "succeed";
}
}
拦截器类
package my.bag.interceptor;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
public class ActionInterceptor implements Interceptor{
public void destroy() {
// TODO Auto-generated method stub
}
public void init() {
System.out.println(" start ");
}
public String intercept(ActionInvocation arg0) throws Exception {
return "succeed";
}
}
index.jsp页面
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'index.jsp' starting page</title>
</head>
<body>
<form action="<%=request.getContextPath()%>/myActionDemo01">
手机号码 :<input type="text" name="mobile"/>
<%
String mobile = (String)request.getParameter("mobile");
request.getSession().setAttribute("mobile",mobile);
%>
<input type="submit" value="submit" name="submit"/>
</form>
</body>
</html>
verfy.jsp页面
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'verfy.jsp' starting page</title>
</head>
verfy.........
<body>
</body>
</html>
哪里错了....
错误信息--
警告: Unable to load config class my.bag.Interceptor.ActionInterceptor at interceptor - file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%206.0/webapps/StrutsDemo11/WEB-INF/classes/struts.xml:9:93 probably due to a missing jar, which might be fine if you never plan to use the ActionInterceptorClass interceptor
2010-8-29 9:34:50 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
严重: Actual exception
严重: Dispatcher initialization failed
严重: Exception starting filter struts2
严重: Error filterStart
2010-8-29 9:34:50 org.apache.catalina.core.StandardContext start
严重: Context [/StrutsDemo11] startup failed due to previous errors
<form action="<%=request.getContextPath()%>/myActionDemo01.action">
改为了<form action="<%=request.getContextPath()%>/myActionDemo01.action" method="post"> 展开
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<package name="itcast" extends="struts-default">
<interceptors>
<interceptor name="myInterceptor" class="my.bag.interceptor.ActionInterceptor"/>
<interceptor-stack name="InterceptorStack">
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="myInterceptor"/>
</interceptor-stack>
</interceptors>
<global-results>
<result name="succeed">/verfy.jsp</result>
</global-results>
<action name="myActionDemo01" class="my.bag.action.myAction">
<interceptor-ref name="InterceptorStack"/>
</action>
</package>
</struts>
Action类
package my.bag.interceptor;
import com.opensymphony.xwork2.ActionSupport;
public class myAction {
public String execute(){
return "succeed";
}
}
拦截器类
package my.bag.interceptor;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;
public class ActionInterceptor implements Interceptor{
public void destroy() {
// TODO Auto-generated method stub
}
public void init() {
System.out.println(" start ");
}
public String intercept(ActionInvocation arg0) throws Exception {
return "succeed";
}
}
index.jsp页面
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'index.jsp' starting page</title>
</head>
<body>
<form action="<%=request.getContextPath()%>/myActionDemo01">
手机号码 :<input type="text" name="mobile"/>
<%
String mobile = (String)request.getParameter("mobile");
request.getSession().setAttribute("mobile",mobile);
%>
<input type="submit" value="submit" name="submit"/>
</form>
</body>
</html>
verfy.jsp页面
<%@ page language="java" import="java.util.*" pageEncoding="gbk"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>My JSP 'verfy.jsp' starting page</title>
</head>
verfy.........
<body>
</body>
</html>
哪里错了....
错误信息--
警告: Unable to load config class my.bag.Interceptor.ActionInterceptor at interceptor - file:/C:/Program%20Files/Apache%20Software%20Foundation/Tomcat%206.0/webapps/StrutsDemo11/WEB-INF/classes/struts.xml:9:93 probably due to a missing jar, which might be fine if you never plan to use the ActionInterceptorClass interceptor
2010-8-29 9:34:50 com.opensymphony.xwork2.util.logging.commons.CommonsLogger error
严重: Actual exception
严重: Dispatcher initialization failed
严重: Exception starting filter struts2
严重: Error filterStart
2010-8-29 9:34:50 org.apache.catalina.core.StandardContext start
严重: Context [/StrutsDemo11] startup failed due to previous errors
<form action="<%=request.getContextPath()%>/myActionDemo01.action">
改为了<form action="<%=request.getContextPath()%>/myActionDemo01.action" method="post"> 展开
4个回答
展开全部
哥们我只看了struts.xml
错误:
<interceptor-ref name="InterceptorStack"/>
里面有放拦截器栈的吗?
你可以设置成默认的 对所有的package 下的 Action 起作用
<!-- 设置全局默认的拦截器(写你自己的)-->
<default-interceptor-ref name="InterceptorStack" />
如果只是单个想让Action起作用就在想要拦截的action里设置:
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="myInterceptor"/>
而你调的是单个属性的Action的拦截器 里面却放置了拦截器栈
<action name="myActionDemo01" class="my.bag.action.myAction">
<interceptor-ref name="InterceptorStack"/>
就好比把一个装了两瓶白酒的袋子 硬塞到一个酒盒里 能放的进去吗?
错误:
<interceptor-ref name="InterceptorStack"/>
里面有放拦截器栈的吗?
你可以设置成默认的 对所有的package 下的 Action 起作用
<!-- 设置全局默认的拦截器(写你自己的)-->
<default-interceptor-ref name="InterceptorStack" />
如果只是单个想让Action起作用就在想要拦截的action里设置:
<interceptor-ref name="defaultStack"/>
<interceptor-ref name="myInterceptor"/>
而你调的是单个属性的Action的拦截器 里面却放置了拦截器栈
<action name="myActionDemo01" class="my.bag.action.myAction">
<interceptor-ref name="InterceptorStack"/>
就好比把一个装了两瓶白酒的袋子 硬塞到一个酒盒里 能放的进去吗?
Storm代理
2023-08-29 广告
2023-08-29 广告
"StormProxies是全球大数据IP资源服务商,其住宅代理网络由真实的家庭住宅IP组成,可为企业或个人提供满足各种场景的代理产品。点击免费测试(注册即送1G流量)StormProxies有哪些优势?1、IP+端口提取形式,不限带宽,I...
点击进入详情页
本回答由Storm代理提供
展开全部
报什么错误
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<form action="<%=request.getContextPath()%>/myActionDemo01.action">
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
应该是少了必要的jar包,看看情况先
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询