jsp json服务器:500错误

发布于 2024-10-29 15:29:02 字数 1971 浏览 1 评论 0原文

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

我得到的响应是:

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 代码是:

<%@ 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。 我在这里做错了什么?

I am trying to integrate json through a jquery ajax request in jsp. I am using org.json.simple package for this. Every thing is fine from client end, but from server response I am getting an 500 server code error, and 4 readyState code.

The response I am getting is:

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:

The jsp code I am using to send response is:

<%@ 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>

I am using eclipse IDE. I have imported the jar file in the project. I have restarted server and restarted eclipse too.
What am i doing wrong here?!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

何以畏孤独 2024-11-05 15:29:02

如果在发送响应的 Web 应用程序的类路径中找不到 json-simple.jar,您会收到该消息。

You can get that message if json-simple.jar is not found in the classpath in the webapp that is sending the response.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文