我在使json在jsp页面中工作时遇到错误.如何调试呢? [英] Error I got while trying to make json work in a jsp page . How to debug this?

查看:138
本文介绍了我在使json在jsp页面中工作时遇到错误.如何调试呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<%@ page language="java" import="net.sf.json.JSONArray" %>

 <%
  JSONArray arrayObj=new JSONArray();
   arrayObj.add("MCA");
   arrayObj.add("Amit Kumar");
   arrayObj.add("19-12-1986");
   arrayObj.add(24);
   arrayObj.add("Scored");
   arrayObj.add(new Double(66.67));
%>
<h2>Array Object is =></h2> <%=arrayObj%>
<br><hr>
<%  for(int i=0;i<arrayObj.size();i++){  %>
          <%=arrayObj.getString(i)%>
<%
  }
%>

我得到的错误是这个

org.apache.jasper.JasperException: Unable to compile class for JSP: 

An error occurred at line: 6 in the generated java file
Only a type can be imported. net.sf.json.JSONArray resolves to a package

An error occurred at line: 19 in the jsp file: /index.jsp
JSONArray cannot be resolved to a type
16:         <%@ page language="java" import="net.sf.json.JSONArray" %>
17:  
18:         <%
19:         JSONArray arrayObj=new JSONArray();
20:         arrayObj.add("MCA");
21:          arrayObj.add("Amit Kumar");
22:          arrayObj.add("19-12-1986");


An error occurred at line: 19 in the jsp file: /index.jsp
JSONArray cannot be resolved to a type
16:         <%@ page language="java" import="net.sf.json.JSONArray" %>
17:  
18:         <%
19:         JSONArray arrayObj=new JSONArray();
20:         arrayObj.add("MCA");
21:          arrayObj.add("Amit Kumar");
22:          arrayObj.add("19-12-1986");

如何调试此错误?我已经下载了Json库,并将其放在Tomcat/webapps/star/WEB-INF/lib中.

How to debug this error ? I have downloaded the Json library and have put it in Tomcat/webapps/star/WEB-INF/lib.

星号是包含jsp页面的文件夹.

Where star is the folder that contains the jsp page.

推荐答案

要么JSON库不在您认为的位置,要么您下载的JSON库的JAR文件根本不包含该类. .使用ZIP或RAR工具调查JAR文件. JAR中应该有一个net/sf/json/JSONArray.class文件.如果缺少该文件,则您可能下载了错误的库.

Either the JSON library is not there where you think it is, or the JAR file of the JSON library which you've downloaded simply doesn't contain that class. Investigate the JAR file using a ZIP or RAR tool. There should be a net/sf/json/JSONArray.class file inside the JAR. If it is missing, then you probably downloaded the wrong library.

这篇关于我在使json在jsp页面中工作时遇到错误.如何调试呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆