首先是一个index.jsp,里面用到了<frameset></frameset>,代码如下:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@ include file="../common/common.jsp"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <base href="${pageScope.basePath}"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="Cache-Control" content="no-cache"> <meta http-equiv="Expires" content="0"> <title>主页-管理者页面</title> <link href="css/style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="js/adminindex.js"></script> </head> <frameset> <frame src="admin/redirpage.action"></frame> </frameset> </html>
<frame>的src是一个action,这是我的action配置(struts.xml),请看<package name="admin" namespace="/admin">的包:
<?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> <constant name="struts.enable.DynamicMethodInvocation" value="true"/> <constant name="struts.devMode" value="true"/> <!--Common package--> <package name="common" namespace="/" extends="struts-default"> <!--iframe页面包含跳转--> <!--登录跳转--> <action name="login"> <result> /WEB-INF/views/login.jsp </result> </action> <!--登录验证--> <action name="check*" class="net.yuanedu.action.AdminAction" method="{1}"> <!--与Ajax有关的用户名、密码、验证码校验--> <result name="success" type="stream"> <!-- 指定下载文件的文件类型 --> <param name="contentType"> text/html </param> <!-- 指定由getResult()方法返回输出结果的InputStream --> <param name="inputName"> inputStream </param> </result> <!--角色判断--> <result name="admin" type="redirectAction"> /Admin_login.action </result> <result name="commissioner" type="redirectAction"> /Commissioner_login.action </result> <result name="finance" type="redirectAction"> /Finance_login.action </result> <result name="reception" type="redirectAction"> /Reception_login.action </result> </action> <!--主页跳转--> <action name="*_*" class="net.yuanedu.action.{1}Action" method="{2}"> <result name="success"> /WEB-INF/views/{1}/index.jsp </result> </action> </package> <!--Admin package--> <package name="admin" namespace="/admin" extends="struts-default"> <action name="redirpage" class="net.yuanedu.action.RedirectAction"> <result name="jump">a.jsp</result> </action> </package> <!--Commissioner package--> <package name="commissioner" namespace="/commissioner" extends="struts-default"> </package> <!--Finance package--> <package name="finance" namespace="/finance" extends="struts-default"> </package> <!--Reception package--> <package name="reception" namespace="/reception" extends="struts-default"> </package> </struts>
现在的问题是,我跑index.jsp,报不能实例化Action的错误(Unable to instantiate Action)。我检查了好久,也怀疑过是namespace的问题,但是我都试过了,还是一样的错误提示。通配符的问题我也调试过,还是没有解决。现在怀疑是jar包的问题。请各位指教,希望能给出详细的解答,非常谢谢!!!。下面是错误提示:
Struts Problem Report Struts has detected an unhandled exception: Messages: net.yuanedu.action.redirpageAction Unable to instantiate Action, net.yuanedu.action.redirpageAction, defined for 'redirpage' in namespace '/'net.yuanedu.action.redirpageAction File: org/apache/catalina/loader/WebappClassLoader.java Line number: 1,645 Stacktraces Unable to instantiate Action, net.yuanedu.action.redirpageAction, defined for 'redirpage' in namespace '/'net.yuanedu.action.redirpageAction com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:318) com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:399) com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:198) org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61) org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39) com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58) org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475) org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) java.lang.Thread.run(Unknown Source) java.lang.ClassNotFoundException: net.yuanedu.action.redirpageAction org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1645) org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1491) com.opensymphony.xwork2.util.ClassLoaderUtil.loadClass(ClassLoaderUtil.java:157) com.opensymphony.xwork2.ObjectFactory.getClassInstance(ObjectFactory.java:107) com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:160) com.opensymphony.xwork2.ObjectFactory.buildBean(ObjectFactory.java:150) com.opensymphony.xwork2.ObjectFactory.buildAction(ObjectFactory.java:120) com.opensymphony.xwork2.DefaultActionInvocation.createAction(DefaultActionInvocation.java:299) com.opensymphony.xwork2.DefaultActionInvocation.init(DefaultActionInvocation.java:399) com.opensymphony.xwork2.DefaultActionProxy.prepare(DefaultActionProxy.java:198) org.apache.struts2.impl.StrutsActionProxy.prepare(StrutsActionProxy.java:61) org.apache.struts2.impl.StrutsActionProxyFactory.createActionProxy(StrutsActionProxyFactory.java:39) com.opensymphony.xwork2.DefaultActionProxyFactory.createActionProxy(DefaultActionProxyFactory.java:58) org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:475) org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:395) org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235) org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191) org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127) org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298) org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:857) org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588) org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489) java.lang.Thread.run(Unknown Source) You are seeing this page because development mode is enabled. Development mode, or devMode, enables extra debugging behaviors and reports to assist developers. To disable this mode, set: struts.devMode=false in your WEB-INF/classes/struts.properties file.
注:这是小的CRM练习,没有用Spring,只用了Struts2和Hibernate