gpt4 book ai didi

java - 将 openCV 与 jsp 一起使用会导致 UnsatisfiedLinkError?

转载 作者:行者123 更新时间:2023-12-01 13:38:44 27 4
gpt4 key购买 nike

这是我在 jsp 页面中放置的代码,只是为了测试它是否正常工作。jsp 页面可以正常工作,无需使用任何 opencv 类。但是我在使用 opencv 库的对象时遇到了这个错误。

<%@ page import="org.opencv.core.*" %>
<%@ page import="org.opencv.highgui.Highgui" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Title</title>
</head>
<body>
<%
System.loadLibrary("opencv_java248");
Mat img = Highgui.imread("F:/project/im2.jpg");
%>

</body>
</html>

附上错误页面以了解详细信息: enter image description here

错误代码是:

Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:553)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:442)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


root cause
javax.servlet.ServletException: java.lang.UnsatisfiedLinkError: org.opencv.highgui.Highgui.imread_1(Ljava/lang/String;)J
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:911)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:840)
org.apache.jsp.first_jsp._jspService(first_jsp.java:79)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)


root cause
java.lang.UnsatisfiedLinkError: org.opencv.highgui.Highgui.imread_1(Ljava/lang/String;)J
org.opencv.highgui.Highgui.imread_1(Native Method)
org.opencv.highgui.Highgui.imread(Highgui.java:359)
org.apache.jsp.first_jsp._jspService(first_jsp.java:68)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:391)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

最佳答案

不满意的链接错误告诉您,没有找到具有此类名称的库。参见这里:OpenCV + Java = UnsatisfiedLinkError .

顺便说一句,您确实不应该在 JSP 中使用代码。创建一个对图像执行所需操作的 Servlet,将其路径/URL 添加为属性 request.setAttribute("key", "value")

使用 RequestDispatcher :

getServletContext().getRequestDispatcher("/path/to/page.jsp").forward(请求,响应)

将请求和响应转发到JSP。然后您可以使用 ${key} 引用它。

关于java - 将 openCV 与 jsp 一起使用会导致 UnsatisfiedLinkError?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21030160/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com