在WEB-INF目录下创建lib目录,并把第三方jar包复制到该目录下
右键lib目录,添加为库
改为模块库
确定后,就可以在JSP中导入后使用第三方jar包的类了。
<%@ page import="FileProcess.WriteStr" %>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
<title>JSP - Hello World</title>
</head>
<body>
<%
String path = "/usr/local/custom1/1.txt";
WriteStr.write(path, "HelloWorld\n", false, "UTF-8");
WriteStr.write(path, "I like C\n", true, "UTF-8");
WriteStr.write(path, "I like C++\n", true, "UTF-8");
out.print("操作完成");
%>
</body>
</html>
在本地的tomcat里运行会报错,可是放到linux中是可以正常运行的。