我写了一个类,下面有查询的方法
public static JSONArray getOder(HttpServletRequest request) {
JSONArray jsonArray = null;
String oderid = StringUtil.getRequestString(request,"id");
String orderid = StringUtil.getRequestString(request,"orderid");
String price = StringUtil.getRequestString(request,"price");
String quantity = StringUtil.getRequestString(request,"quantity");
String shop_id = StringUtil.getRequestString(request,"shop_id");
String subtotal = StringUtil.getRequestString(request,"subtotal");
StringBuffer sql = new StringBuffer(" select orderid,quantity,shop_id,subtotal,name,price from ORDER_DETAIL where 1=1 and orderid="+oderid);
List<DynaBean> list = DataBaseOperator.queryList(sql.toString());
jsonArray = JsonUtil.listDynaBeanToJson(list);
return jsonArray;
在JS里排版FOR循环输出JSP页面数组
<%
JSONArray jsonArray = ManagerService.getOder(request);
%>
<script type="text/javascript">
var dataArray= <%=jsonArray%>;
</script>
我想在查询的时候 如果数据库返回为空,则在跳转的页面提示为空,请问在哪里判断比较好呢? 该怎么判断呢?
public static JSONArray getOder(HttpServletRequest request) {
JSONArray jsonArray = null;
String oderid = StringUtil.getRequestString(request,"id");
String orderid = StringUtil.getRequestString(request,"orderid");
String price = StringUtil.getRequestString(request,"price");
String quantity = StringUtil.getRequestString(request,"quantity");
String shop_id = StringUtil.getRequestString(request,"shop_id");
String subtotal = StringUtil.getRequestString(request,"subtotal");
StringBuffer sql = new StringBuffer(" select orderid,quantity,shop_id,subtotal,name,price from ORDER_DETAIL where 1=1 and orderid="+oderid);
List<DynaBean> list = DataBaseOperator.queryList(sql.toString());
jsonArray = JsonUtil.listDynaBeanToJson(list);
return jsonArray;
在JS里排版FOR循环输出JSP页面数组
<%
JSONArray jsonArray = ManagerService.getOder(request);
%>
<script type="text/javascript">
var dataArray= <%=jsonArray%>;
</script>
我想在查询的时候 如果数据库返回为空,则在跳转的页面提示为空,请问在哪里判断比较好呢? 该怎么判断呢?
解决方案 »
- 我的myclipase 10.7没有uml怎么办呢
- 关于SSH一个小项目的问题
- 北京求职联盟qq群23776894 一起去找工作
- 问题一个2个项目接口的问题
- 怎么防止struts是不是重复提交
- 有两个按钮,一个“暂停”,一个是“开始执行”。java如何让程序暂停、执行。
- 熟悉移动彩信MM7api的兄弟请进来解释两个小问题,(我是新手)。200分相送,绝不食言!
- 30分问一个jsp文字编码问题!
- 子画面的问题, 高手进!!!!!
- 对初学者,除了JBULIDER,还有什么工具比较合适(且容易找到)?
- netbeans中自带的tomcat服务器,如何自动启动!
- oracle 中如何随机取出从51到100之间的记录,请高手指教
if(list.size<1){
return null;
}else{jsonArray = JsonUtil.listDynaBeanToJson(list);
return jsonArray;
}
<%
JSONArray jsonArray = ManagerService.getOder(request);
if(jsonArray == null){
response.sendRedirect("main.jsp");
}
%>
var dataArray= <%=jsonArray%>;
if (!dataArray) alert("没东西啊!");
</script>