Java 如何在jsp应用程序中引用外部jar?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1719824/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to reference an external jar in jsp app?
提问by Southsouth
I am new to Eclipse. I am trying to run a jsp example using iText to generate a PDF, I put iText.jar file in Referense Library folder, but when I ran the jsp, I got error message that the class Document defined in the iText,jar can't not be resolved.
我是 Eclipse 的新手。我正在尝试使用 iText 运行一个 jsp 示例来生成 PDF,我将 iText.jar 文件放在了 Referense Library 文件夹中,但是当我运行 jsp 时,我收到错误消息,iText,jar 中定义的类 Document 不能无法解决。
回答by Asaph
Right click on your project folder in the navigator, choose properties, choose java build path, select the libraries tab, click Add External Jars..., choose your jar. Click OK.
在导航器中右键单击您的项目文件夹,选择属性,选择 java 构建路径,选择库选项卡,单击添加外部罐子...,选择您的罐子。单击确定。
回答by Richie
You can also add this jar into the project lib folder(present in WEB-INF, if not present you can add a folder in WEB-INF).
您也可以将此jar添加到项目lib文件夹中(存在于WEB-INF中,如果不存在,您可以在WEB-INF中添加一个文件夹)。
Now you can either
现在你可以
Right click on your project folder in the navigator, choose properties, choose java build path, select the libraries tab, click Add External Jars..., choose your jar. Click OK.
在导航器中右键单击您的项目文件夹,选择属性,选择 java 构建路径,选择库选项卡,单击添加外部罐子...,选择您的罐子。单击确定。
or
或者
Right click on your project folder in the navigator, choose properties, choose java build path, select the libraries tab, click Add Jars..., choose your jar. Click OK.
在导航器中右键单击您的项目文件夹,选择属性,选择 java 构建路径,选择库选项卡,单击添加罐子...,选择您的罐子。单击确定。
Hope this helps..
希望这可以帮助..
回答by Bozho
- Add the jar in WEB-INF/lib
- add
<%@ page import="com.lowagie.itext.Document" %>
(or whatever the package is) to the top of your JSP
- 在 WEB-INF/lib 中添加 jar
- 添加
<%@ page import="com.lowagie.itext.Document" %>
(或任何包)到您的 JSP 的顶部