<%@ 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)%>
<%
}
%>
l'erreur que je reçois est ceErreur que j'ai eu en essayant de faire fonctionner json dans une page jsp. Comment déboguer ça?
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");
Comment déboguer cette erreur? J'ai téléchargé la bibliothèque JSON et l'ai mise dans Tomcat/webapps/star/WEB-INF/lib.
Où étoile est le dossier qui contient la page jsp.
* Rien à voir avec le problème: la JSP est le mauvais endroit pour ce travail. Vous pouvez trouver les exemples dans [cette réponse] (http://stackoverflow.com/questions/4112686/update-current-page-with-a-servlet) utiles. * – BalusC