首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Ajax >

Ajax入门事例

2012-10-28 
Ajax入门例子index.jsp?struts_config.xml?TempAction.java@Overridepublic ActionForward execute(Action

Ajax入门例子

index.jsp

?

struts_config.xml

?

TempAction.java

@Overridepublic ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletResponse response)throws Exception {PrintWriter pw = response.getWriter();SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");String today = df.format(new Date());//(1)这里的print就是index.jsp中要获取的responseTextpw.print(today);//(2)记得要flushpw.flush();//(3)如果是ajax的请求,这里不要返回页面,不然会将整个页面html源码赋值到responseText中return null;}
?

热点排行