无法使用org.apache.commons.lang.StringUtils包

use*_*779 9 java jdeveloper package

我是Jdeveloper的新手,我正在编写一个在两个字符串之间使用文本的程序.我偶然发现了StringUtils.substringBetween()函数,但是当我编译程序时,它说它找不到变量StringUtils并且无法识别org.apache.commons.lang.StringUtils包.请告诉我哪里出错了.我认为有一件事是库中没有包,但由于我是新手,我不知道如何安装这样的包或在哪里安装.我使用的是jdev 10.1.3.5.0.我在网上偶然发现的代码是这样的:

import java.util.Date;

import org.apache.commons.lang.StringUtils;

public class NestedString {

    public static void main(String[] args) {

        String helloHtml = "<html>" + "<head>" + " <title>Hello World from Java</title>"
                + "<body>" + "Hello, today is: " + new Date() + "</body>" + "</html>";
        String title = StringUtils.substringBetween(helloHtml, "<title>", "</title>");
        String content = StringUtils.substringBetween(helloHtml, "<body>", "</body>");
        System.out.println("title = " + title);
        System.out.println("content = " + content);
    }
}
Run Code Online (Sandbox Code Playgroud)

Abh*_*hek 5

从apache jakarta sie下载apache-lang常见文件:

http://commons.apache.org/lang/

获取jar文件后,请将此jar放在项目的构建路径中,如果您无法找到构建路径,请转到Jdeveloper帮助文件并键入"构建路径",然后您将获得所有内容.


Udo*_*eld 0

下载commons-lang并将其放入 /WEB-INF/lib 文件夹中。

如果它不是 Web 应用程序,您必须检查如何使用 JDeveloper 将其添加到构建路径中。