首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jsp json服务器: 500错误

jsp json服务器: 500错误
EN

Stack Overflow用户
提问于 2011-04-03 00:00:29
回答 1查看 2.2K关注 0票数 0

我正在尝试通过jsp中的jquery ajax请求来集成json。我使用org.json.simple包来实现这一点。从客户端来看,一切都很好,但从服务器响应中,我得到了一个500服务器代码错误和4个readyState代码。

我得到的回应是:

代码语言:javascript
复制
description The server encountered an internal error () that prevented it from fulfilling this request.

exception

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

An error occurred at line: 12 in the generated java file
Only a type can be imported. org.json.simple.JSONObject resolves to a package

An error occurred at line: 15 in the jsp file: /interceptor_primaryengine_save.jsp
JSONObject cannot be resolved to a type
12: <body>
13: <%
14: 
15:   JSONObject obj = new JSONObject();
16:   
17:    String value = request.getParameter("value");
18:     obj.put("value",value);


An error occurred at line: 15 in the jsp file: /interceptor_primaryengine_save.jsp
JSONObject cannot be resolved to a type
12: <body>
13: <%
14: 
15:   JSONObject obj = new JSONObject();
16:   
17:    String value = request.getParameter("value");
18:     obj.put("value",value);


Stacktrace:

我用来发送响应的jsp代码是:

代码语言:javascript
复制
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page
    import="org.jdom.*,java.util.*,org.jdom.input.SAXBuilder,org.jdom.output.XMLOutputter,java.io.*,org.jdom.filter.*,org.json.simple.JSONObject"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<%

  JSONObject obj = new JSONObject();

   String value = request.getParameter("value");
    obj.put("value",value);
    out.print(value);
   out.flush();
  %>
</body>
</html>

我使用的是eclipse IDE。我已经在项目中导入了jar文件。我重新启动了服务器,也重新启动了eclipse。我到底做错了什么?!

EN

回答 1

Stack Overflow用户

发布于 2011-04-03 00:31:07

如果在发送响应的webapp的类路径中找不到json-simple.jar,则可以获得该消息。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5524216

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档