JSP页面:
//动态获取列的信息
function tankToWeb() {
var storeIndex=document.getElementByI('storeIndex').value;
if(storeIndex=="") return false;
var myAjax = new Ajax.Request('archiveTankGrid.do?service=tankToWeb',
{
method: 'post',parameters: 'wareHouse='storeIndex,
onComplete: function(response) {
var ret = response.responseText;
if(ret=="error"){
alert("选择出错!");
return false;
}else
{
ret="<select name='archiveTankLineVo.tankIndex' style='width:100px'><option value=''>--请选择--</option>"+ret;
ret=ret+"</select>";
document.getElementById("testid").innerHTML=ret;
return true;
}
}
});
}
action 中service=tankToWeb 调用查询方法
//2.根据机构、库房ID获取档案柜列
private void tankToWeb(){
String returnName="";
HttpServletRequest request = ServletActionContext.getRequest();
HttpServletResponse response = ServletActionContext.getResponse();
response.setCharacterEncoding("GBK");
response.setContentType("text/html;charset=GBK");
String wareHouse=request.getParameter("wareHouse");
String orgId=request.getParameter("orgId");
String gtType=Util.getParameterValue(request.getParameter("gtType"));
try {
PrintWriter out = response.getWriter();
returnName= getArchiveTank(orgId,wareHouse,gtType);
out.println(returnName);
out.close();
} catch (Exception e) {
try {
PrintWriter out = response.getWriter();
System.out.println("tankToWeb出错!");
out.println("error");
out.close();
} catch (IOException e1) {
e1.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
}
public String getArchiveTank(String orgId,String storeIndex,String gtType){
//String hql="select tankIndex,tankName from T_ArchiveTank where storeIndex='"+storeIndex+"' order by tankIndex";
String hql = "select distinct tankIndex,tankName from T_ArchiveTankGrid where orgId='"+orgId+"' and storeIndex='"+storeIndex+"' order by tankIndex";
List list = archiveTankService.findArchiveTankByStoreIndex(hql);
String retStr="";
Iterator it=list.iterator();
if("0".equals(gtType)){
while(it.hasNext()){
Object[] obj=(Object[])it.next();
retStr+="<option value="+obj[0].toString()+">"+obj[0].toString()+"</option>";
}
}else{
while(it.hasNext()){
Object[] obj=(Object[])it.next();
retStr+="<option value="+obj[0].toString()+">"+obj[1].toString()+"</option>";
}
}
return retStr;
}
分享到:
相关推荐
Ajax案例(JSP)Ajax案例(JSP)Ajax案例(JSP)Ajax案例(JSP)Ajax案例(JSP)Ajax案例(JSP)Ajax案例(JSP)Ajax案例(JSP)
Ajax案例详解Ajax案例详解Ajax案例详解Ajax案例详解Ajax案例详解
整合ssh+ajax案例.doc 整合ssh+ajax案例.doc 整合ssh+ajax案例.doc
AJAX案例基础学习:AJAX案例.xls
aspx实现ajax案例
ASP.Net的Ajax案例。
Ajax案例: 案例一:通过Ajax获取服务器时间; 案例二:通过Ajax验证用户名; 案例三:通过Ajax进行登录。
如何创建Ajax案例代码
TP393.09W404Ajax经典案例开发大全 ajax案例,里面有非常有用的Ajax例子。
机器人Ajax案例.zip
ajaX 案例大全以及基本操作代码 经典 大家可以下下
AJAX案例研究之Gmail
JavaWeb之ajax案例—省市联动:客户端通过ajax请求服务器端获得xml文件中的各省的名称,通过选择省,再加载市的名称
jQuery使用AJAX案例代码,ASP开发。
是一些在asp.net程序中使用ajax的案例
很好的ajax案例,比较适合初学者学习,java版的哦
AJAX案例研究之详细剖析Gmail应用
传智播客赵君老师视频讲解:基于jquery的ajax案例和练习.
ajax案例,都是老师精挑好的例子,当然也是常用得..
AJAX案例(未设计dao层代码,X马)