0

嗨,我有一个要求,我必须检查 struts 动作类中的某些内容,然后使用在 JS fx 中调用的 ajax 调用将结果发送回浏览器。问题是我无法点击动作类并且控制台正在抛出以下错误: org.apache.struts.action.RequestProcessor processActionCreate No action instance for path /ChangePwdAjax could be created java.lang.ClassNotFoundException:test.ChangePwdAjaxAction.java

类已编译且包上下文有效 test.ChangePwdAjaxAction.java

任何想法我做错了什么以及在哪里做错了?

这是我到目前为止所写的。

JS代码

function checkError()
{
var valuePassword="test";

var url = "/test/ChangePwdAjax.do?newPass="+valuePassword;
        var xmlHTTP = getXMLHTTPRequest();


        xmlHTTP.onreadystatechange = function() { 
        handleResponse(xmlHTTP); }

        xmlHTTP.open("GET",url,true);

        xmlHTTP.send();


}

function handleResponse(xmlHTTP){
    alert("handleResponse");
        if (xmlHTTP.readyState == 4 && xmlHTTP.status == 200) {
            alert("handleResponse");
            var xmlDoc = xmlHTTP.responseXML;

            alert(xmlDoc.documentElement.getElementsByTagName("pwdFlag")[0].text);

        }       
    }

function getXMLHTTPRequest(){
    alert("getXMLHTTPRequest");
        if (window.XMLHttpRequest) {
            return new XMLHttpRequest();
        }
        // IE
        else if (window.ActiveXObject) {
            return new ActiveXObject("Microsoft.XMLHTTP");
        }
        else{
        alert("XMLHttpRequest is not supported!");
        }
    }

动作类代码

public class ChangePwdAjaxAction extends Action {


    public ActionForward execute(final ActionMapping mapping, final ActionForm form,
            final HttpServletRequest request,final HttpServletResponse response)

    {

        System.out.println("----IN--AJAX ACTION----------");
        final HttpSession session= request.getSession(false);

        if(session==null || session.getAttribute("user_id")==null){

            return mapping.findForward("sessionexpired");
        }


        final String user_id=(String)session.getAttribute("user_id");

        try{


            final BusinessDelegate busdel=new BusinessDelegate(user_id,session.getId());

            String newpwd = (String)request.getParameter("newPass");



            boolean b=busdel.checkOldPWd(user_id, newpwd);
            //checking return values from bus delegate
            response.setContentType("text/xml");
            PrintWriter printwriter = response.getWriter();

            printwriter.println("<?xml version=\"1.0\"?>");
            printwriter.println("<Root>");

            if(b)
            {
                System.err.println("----New password Failed--Y--------");   
            printwriter.println("<pwdFlag>"+"Y"+"</pwdFlag>");
            }
            else
            {
                System.out.println("----New password OK---N-------");   
                printwriter.println("<pwdFlag>"+"N"+"</pwdFlag>");
            }


            printwriter.println("</Root>");


            }catch(Exception e){
                logger.logCommon("Login Action : Login Process in Action : ", "EXCEPTION");
                logger.logError(e);

            }


        return null;
    }


}

Struts-config 入口

<action path="/ChangePwdAjax" type="test.ChangePwdAjaxAction.java"/>
4

1 回答 1

0

哎呀,这必须是

动作路径="/ChangePwdAjax" type="test.ChangePwdAjaxAction"/>

而不是

动作路径="/ChangePwdAjax" type="test.ChangePwdAjaxAction.java"/>

于 2012-11-08T08:46:25.330 回答