我刚刚将org.json
库导入了我的动态Web项目。作为服务器,我正在使用Tomcat
。当我尝试运行应用程序时出现此错误:java.lang.NoClassDefFoundError: org/json/JSONObject
。这是我收到错误的代码:
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String pathInfo = request.getPathInfo();
if(pathInfo != null){
String newPathInfo = pathInfo.substring(1);
System.out.println("--> " + pathInfo);
System.out.println("--> " + newPathInfo);
System.out.println("parameter --> " + request.getParameter("format"));
String format = request.getParameter("format");
if(format != null){
if(format.equals("json")){
System.out.println("Preparing JSON reply...");
response.setContentType("text/json");
JSONObject obj = new JSONObject();
obj.put("salutation", lang.get(newPathInfo));
response.getWriter().write(obj.toString());
System.out.println("--> "+obj.toString());
}
}
}
具体来说,这是我收到错误的行:
obj.put("salutation", lang.get(newPathInfo));
我有什么遗失的吗?
谢谢!
答案 0 :(得分:1)
我已将该库复制到WEB-INF/lib
文件夹,但它正在运行