我正在用jsp做项目,其中我需要调用外部类的某些方法,并且该方法的结果必须由jsp接收以进行进一步处理。返回的结果为图像形式。
例如,
Key=Crypting.KeyGen(width,height);
Encrypt=Crypting.Encrypt(Key,Src);
我的疑问是,这种调用外部方法的正确方法是吗?
尝试遵循代码...
样例代码
在类文件中的方法应该是 public
//Here Test class inside com.example packege
package com.example;
public class Test {
public static String displayInfo(){
return "This is Display Method...";
}
}
在JSP文件中,您需要分别导入包类。
// JSP File and here calling Test Class displayInfo() Static method
<%@page import="com.example.Test"%>
<html>
<body>
<h1>Hello World!!!</h1>
<%
out.print("welcome to jsp "+Test.displayInfo());
%>
</body>
</html>
希望对您有帮助...
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句