如何在我的.jsp页面上创建第三方.jar? [英] How do I make a third party .jar available to my .jsp page?

查看:177
本文介绍了如何在我的.jsp页面上创建第三方.jar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始学习JSP(而且我对Java很新),我想使用 JSON-lib 。我想创建一个这样的页面:

I'm just starting to learn JSP (and I'm pretty new to Java in general), and I'd like to use JSON-lib with it. I want to make a page something like this:

<%@ page import="net.sf.json.JSONObject"%>
<%
String json = new JSONObject().put("hello", "world").toString();
out.println(json);
%>

我下载了json-lib-2.3-jdk15.jar并将其放在与...相同的目录中。 jsp页面。但是我得到了这个错误

I downloaded json-lib-2.3-jdk15.jar and put it in the same directory as the .jsp page. But I get this error

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.JSONObject resolves to a package

An error occurred at line: 3 in the jsp file: /getCard.jsp
JSONObject cannot be resolved to a type
1: <%@ page import="net.sf.json.JSONObject" %>
2: <%
3: String json = new JSONObject().put("hello", "world").toString();
4: out.println(json);
5: %>
6: 

如何将JSONObject类提供给我的.jsp页面?

How do I make the JSONObject class available to my .jsp page?

推荐答案

您需要使用Web应用程序部署该jar文件。通常你必须把它放在WEB-INF / lib /文件夹中。

You need to deploy that jar file with your web application. Usually you have to put it in WEB-INF/lib/ folder.

这篇关于如何在我的.jsp页面上创建第三方.jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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