struts2中js实现把后台的list传到前台页面显示 我想做一个点击一个下拉框中的选项,然后在这个页面的下方显示该选项下的一些字段信息。高手帮帮忙,搞了快两天了。在线等啊!!!! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 onchange出发js,用ajax发送下拉框选中选项的value给struts,返回一段文字,回调函数写进div 能具体点吗?我刚学这玩意function redirect(){ alert("000000000"); $.ajax({ type:"get", url:"../CategoryFileManagerO/cfmaction8.action", data:{achid:$("#cglb").val()}, dataType:"json", success: function(data) { $.each(data,function(apptargetlist, apptarget) { alert(apptarget.tarname); }) } },"json"); }我得到了后台的数据,但怎么显示到页面?还有得到的可能是字符串形式的 我的qq是774087258,你能不能加qq详细给我说一下,我这时间比较紧 <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>My JSP 't.jsp' starting page</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" src="jquery-1.4.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#test").click(function(){ $.ajax({ url:"testAction!ajax.action", type:"post", data:{id:1}, success:function(result){ $("#div").html(result); } }); }); }); </script> </head> <body> <input type="button" id="test" value="show"> <div id="div"></div> </body></html> <%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>My JSP 't.jsp' starting page</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" src="jquery-1.4.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("#test").click(function(){ $.ajax({ url:"testAction!ajax.action", type:"post", data:{id:1}, success:function(result){ $("#div").html(result); } }); }); }); </script> </head> <body> <input type="button" id="test" value="show"> <div id="div"></div> </body></html> result是什么数据类型?String还是list?如果是list的话,我想用迭代器在页面上显示出来,该怎么写? public String querryAppTarget(){ System.out.println("进入action的querryAppTarget方法"); System.out.println("01"); System.out.println(achid); apptargetlist = new ArrayList<AppTarget>(); apptargetlist = cfmdao.querryAppTarget(achid); jsonrusult=JSONArray.fromObject(apptargetlist); System.out.println("02"); return this.SUCCESS; } ---------------------这是我后台的action------------------------------- function redirect(){ alert("000000000"); $.ajax({ type:"get", url:"../CategoryFileManagerO/cfmaction8.action", data:{achid:$("#cglb").val()}, dataType:"json", success: function(data) { alert(data); $("#resultId").html(data); }}); } --------------前台的jquery------------------[com.hanet.sip.pojo.AppTarget@5fe9c4, com.hanet.sip.pojo.AppTarget@ec5584]------------------这是alert出来的data----------------- 可以把你的List拼成json字符串,再转成js对象操作 能不能具体点?我从后台得到的数据和前台打印出来的完全一样,但是我在前台想输出对象的属性时报defined。 Struts环境搭建好后启动Tomcat报错无法找打sruts.xml 请高手帮忙,JSP中如何使用存储过程? 求一sql语句? 菜鸟求一个关于AJAX局部刷新的代码 想请教大家一个关于静态页内显示相关内容的问题 请问怎么在javabean中使用request和response对象。 Freemarker生产静态页面的一些问题 请大神们进 请帮帮忙!急!!! 谁有MSSQL连接池的例子? 关于日期的,老是出错,请赐教! 求解。Hibernate的优势。 请教几个另初学者混淆的关于(运行/开发)环境的概念问题?
function redirect(){
alert("000000000");
$.ajax({
type:"get",
url:"../CategoryFileManagerO/cfmaction8.action",
data:{achid:$("#cglb").val()},
dataType:"json",
success: function(data) {
$.each(data,function(apptargetlist, apptarget) {
alert(apptarget.tarname);
})
}
},"json");
}
我得到了后台的数据,但怎么显示到页面?还有得到的可能是字符串形式的
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 't.jsp' starting page</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" src="jquery-1.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#test").click(function(){
$.ajax({
url:"testAction!ajax.action",
type:"post",
data:{id:1},
success:function(result){
$("#div").html(result);
}
});
});
});
</script>
</head>
<body>
<input type="button" id="test" value="show">
<div id="div"></div>
</body>
</html>
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 't.jsp' starting page</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" src="jquery-1.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#test").click(function(){
$.ajax({
url:"testAction!ajax.action",
type:"post",
data:{id:1},
success:function(result){
$("#div").html(result);
}
});
});
});
</script>
</head>
<body>
<input type="button" id="test" value="show">
<div id="div"></div>
</body>
</html>
System.out.println("进入action的querryAppTarget方法");
System.out.println("01");
System.out.println(achid);
apptargetlist = new ArrayList<AppTarget>();
apptargetlist = cfmdao.querryAppTarget(achid);
jsonrusult=JSONArray.fromObject(apptargetlist);
System.out.println("02");
return this.SUCCESS;
}
---------------------这是我后台的action-------------------------------
alert("000000000"); $.ajax({
type:"get",
url:"../CategoryFileManagerO/cfmaction8.action",
data:{achid:$("#cglb").val()},
dataType:"json",
success: function(data) {
alert(data);
$("#resultId").html(data);
}});
}
--------------前台的jquery------------------
[com.hanet.sip.pojo.AppTarget@5fe9c4, com.hanet.sip.pojo.AppTarget@ec5584]
------------------这是alert出来的data-----------------