此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
楼主【eeight】截止到2008-07-18 19:32:51的历史汇总数据(不包括此帖):
发帖的总数量:8 发帖的总分数:300 每贴平均分数:37
回帖的总数量:14 得分贴总数量:3 回帖的得分率:21%
结贴的总数量:8 结贴的总分数:300
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:100.00% 结分的百分比:100.00%
无满意结贴率:0.00 % 无满意结分率:0.00 %
敬礼!
楼主【eeight】截止到2008-07-18 19:32:51的历史汇总数据(不包括此帖):
发帖的总数量:8 发帖的总分数:300 每贴平均分数:37
回帖的总数量:14 得分贴总数量:3 回帖的得分率:21%
结贴的总数量:8 结贴的总分数:300
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:100.00% 结分的百分比:100.00%
无满意结贴率:0.00 % 无满意结分率:0.00 %
敬礼!
去掉“/”试下
send("")发送了一些参数、、、、、、、、、、、、
因为现在不在我的电脑上,现在用的这台电脑什么都没有,所以。xmlhttp.open("post","/ajaxaction.do");
xmlhttp.send("name=myname&password=mybirthday");如果在XML中配置了ACTION的path="/ajaxaction";
在JS里是不是直接xmlhttp.open("get","/ajaxaction.do",true);
然后在send(null);就可以访问ACTION???
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>index.jsp</title> <meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<script type="text/javascript">
var XMLHttp = {
_objPool: [], _getInstance: function ()
{
for (var i = 0; i < this._objPool.length; i ++)
{
if (this._objPool[i].readyState == 0 || this._objPool[i].readyState == 4)
{
return this._objPool[i];
}
} // IE5中不支持push方法
this._objPool[this._objPool.length] = this._createObj(); return this._objPool[this._objPool.length - 1];
}, _createObj: function ()
{
if (window.XMLHttpRequest)
{
var objXMLHttp = new XMLHttpRequest(); }
else
{
var MSXML = ['MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'Microsoft.XMLHTTP'];
for(var n = 0; n < MSXML.length; n ++)
{
try
{
var objXMLHttp = new ActiveXObject(MSXML[n]);
break;
}
catch(e)
{
}
}
} // mozilla某些版本没有readyState属性
if (objXMLHttp.readyState == null)
{
objXMLHttp.readyState = 0; objXMLHttp.addEventListener("load", function ()
{
objXMLHttp.readyState = 4;
if (typeof objXMLHttp.onreadystatechange == "function")
{
objXMLHttp.onreadystatechange();
}
}, false);
} return objXMLHttp;
}, // 发送请求(方法[post,get], 地址, 数据, 回调函数)
sendReq: function (method, url, data, callback)
{
var objXMLHttp = this._getInstance(); with(objXMLHttp)
{
try
{
// 加随机数防止缓存
if (url.indexOf("?") > 0)
{
url += "&randnum=" + Math.random();
}
else
{
url += "?randnum=" + Math.random();
} open(method, url, true);
// 设定请求编码方式
setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
send(data);
onreadystatechange = function ()
{
if (objXMLHttp.readyState == 4 && (objXMLHttp.status == 200 || objXMLHttp.status == 304))
{
callback(objXMLHttp);
}
}
}
catch(e)
{
alert(e);
}
}
}
}; function b(obj){
//alert("b");
alert(obj.responseText);
}function a(){
//alert("a");
XMLHttp.sendReq('get',"test.do",null,b);}</script>
</head>
<body>
<form>
<table border="0">
<tr>
<td>Login:</td>
<td><input name="login"/></td>
</tr>
<tr>
<td>Password:</td>
<td><input name="password"/></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="button" onclick="a()" /></td>
</tr>
</table>
</from>
</body>
</html>
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.yourcompany.struts.action;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.yourcompany.struts.form.TestForm;/**
* MyEclipse Struts
* Creation date: 07-18-2008
*
* XDoclet definition:
* @struts.action path="/test" name="testForm" input="/form/test.jsp" scope="request" validate="true"
*/
public class TestAction extends Action {
/*
* Generated Methods
*/ /**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
TestForm testForm = (TestForm) form;// TODO Auto-generated method stub
try {
response.getWriter().print("sssssssssssssssaaa");
} catch (Exception e) {
// TODO: handle exception
}
return null;
}
}<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd"><struts-config>
<data-sources />
<form-beans >
<form-bean name="testForm" type="com.yourcompany.struts.form.TestForm" /> </form-beans> <global-exceptions />
<global-forwards />
<action-mappings >
<action
attribute="testForm"
input="/form/test.jsp"
name="testForm"
path="/test"
scope="request"
type="com.yourcompany.struts.action.TestAction" />
</action-mappings> <message-resources parameter="com.yourcompany.struts.ApplicationResources" />
</struts-config>
struts-config.xml中的配置:
<action path="/deptPage" type="org.springframework.web.struts.DelegatingActionProxy" />js中:
xmlHttp.open("GET","deptPage.do?sql=search¤tPage=1",true);
xmlHttp.onreadystatechange = callback;
xmlHttp.send(null);
GET和POST都试过,后台Action中也没有报错。
这是回调方法
function callback()
{
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200)
{
var xml = xmlHttp.responseText;
document.getElementById("deptTable").innerHTML = xml;
}
else
alert("您所请求的页面有异常。");
}
}
结果: 执行了 alert("您所请求的页面有异常。"); 这句