struts应用程序中的javax.servlet.ServletException

时间:2014-01-30 07:49:11

标签: java servlets struts1

得到javax.servlet.ServletExceptionjava.lang.ClassCastException:com.dna.nsm.sim.action.LogoutAction

在struts 1应用程序中。

错误消息:

javax.servlet.ServletException: java.lang.ClassCastException: com.dna.nsm.sim.action.LogoutAction
    org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)


root cause 

java.lang.ClassCastException: com.dna.nsm.sim.action.LogoutAction
    org.apache.struts.chain.commands.servlet.CreateAction.createAction(CreateAction.java:98)
    org.apache.struts.chain.commands.servlet.CreateAction.getAction(CreateAction.java:68)
    org.apache.struts.chain.commands.AbstractCreateAction.execute(AbstractCreateAction.java:91)
    org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
    org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
    org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:305)
    org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:191)
    org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
    org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
    org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)

LogoutAction代码:

public class LogoutAction  extends Action{
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
        // To redirect to the Login page
        return mapping.findForward("success");
    }
}

Struts-config.xml部分

 <action path="/logout" type="com.dna.nsm.sim.action.LogoutAction" >
            <forward name="success" path="/tiles/login/body.jsp" />
 </action>

建议请。

1 个答案:

答案 0 :(得分:0)

检查您的导入并确保您正在扩展正确的Action类。