惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

月光博客
月光博客
C
Check Point Blog
J
Java Code Geeks
腾讯CDC
Apple Machine Learning Research
Apple Machine Learning Research
宝玉的分享
宝玉的分享
Microsoft Azure Blog
Microsoft Azure Blog
WordPress大学
WordPress大学
量子位
Google DeepMind News
Google DeepMind News
I
InfoQ
The GitHub Blog
The GitHub Blog
aimingoo的专栏
aimingoo的专栏
N
Netflix TechBlog - Medium
Hugging Face - Blog
Hugging Face - Blog
博客园 - Franky
V
V2EX
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
小众软件
小众软件
博客园_首页
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
IT之家
IT之家

博客园 - 笑笑江南

sss IBATIS 延迟加载 iBATIS一对多/多对多N+1问题解决方案 - 笑笑江南 - 博客园 [转]office outlook 2007 如何设置开机自动启动 代码整洁之道 类关系 eclipse 快捷键 9-15 企业数据更新 mysql 常用函数 利用myeclipse生成Hibernate Mapping文件【转】 配置eclipse下tomcat启动参数【转】 安装svneclipse .net 开发相关工具(包)的作用 basicform 与 store gridpanel中拖拽排序 struts2 file 标签产生的一个问题 applyTo ,render, contentel,el,applytomarkup 的区别 呕吐呕吐 tabpanel 添加 tab
使用 ajax 提交数据
笑笑江南 · 2008-11-30 · via 博客园 - 笑笑江南

var Ajax = {

    xmlHttp:

"",
    getYear:
function(){
      
return  document.getElementById("SY").selectedIndex+1900+"";
    },
    getMonth: 
function (){
      
return  document.getElementById("SM").selectedIndex+1+"";
    },
 createXMLHttpRequest:
function () {
      
if (window.ActiveXObject) {
          xmlHttp 
= new ActiveXObject("Microsoft.XMLHTTP");
      }
      
else if (window.XMLHttpRequest) {
          xmlHttp 
= new XMLHttpRequest();
      }
 },
 send:
function () {
   
this.createXMLHttpRequest();
   xmlHttp.onreadystatechange 
= this.showResponse;
   xmlHttp.open(
"POST""DateSetAjax.action?toShowYearMonth="+ leftPad(this.getYear ())+"-"+leftPad(this.getMonth()), false);
   xmlHttp.send(
"yearmonth=aa");
 },
 showResponse:
function(){
    
if(xmlHttp.readyState == 4) {
      
if(xmlHttp.status == 200) {  
       
var data =  xmlHttp.responseText;
       
if(data=="null")
         data 
= "";
       CLD.date1.value
=data;
    }
   }
 }

}

Ajax.send(); 发送请求。

 上面代码 参数必须在附在url 后面 才能在struts2中取到。xmlHttp.send("yearmonth=aa"); 中的参数并不起作用。

send 怎么发送数据呢

ServletActionContext.getRequest().getParameter(key); ok

ActionContext.getContext().get("request").get(key);  null.