struts2框架下用ajax 总是404错误
struts2框架下用ajax 总是404错误
这是调用的action
xmlHttp.open("post","/baidu/StuNoCheck.action?stuNo=" + stuNo,true); xmlHttp.send(null); } function checkStuNoCallback(){ alert(“11”); if(xmlHttp.readyState == 4){ alert(xmlHttp.status); if(xmlHttp.status == 200){ var text = xmlHttp.responseText; 论文网
正常能打印出11 说明就是调用不到我的action
下面试我struts2xml的配置 而且运行时什么错也不报
<package name="myFirst" namespace="/baidu" extends="struts-default"> <action name="StuNoCheck" class="com.dxy.action.StuNoCheck"> <result name="success">/StudentManager/StudentManager.jsp</result> </action>
路径问题,
改为
xmlHttp.open("post","${pageContext.request.contextPath}/baidu/StuNoCheck.action?stuNo=" + stuNo,true);
或者
xmlHttp.open("post","baidu/StuNoCheck.action?stuNo=" + stuNo,true);