嗨我想尝试在jsp页面调用常规java类,并希望在我尝试做的时候在jsp页面上打印一些我没有得到任何输出
这是我的代码
MyClass.java
package Demo;
public class MyClass {
public void testMethod(){
System.out.println("Hello");
}
}
Run Code Online (Sandbox Code Playgroud)
test.jsp的
<%@ page import="Demo.MyClass"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<jsp:useBean id="test" class="Demo.MyClass" />
<%
MyClass tc = new MyClass();
tc.testMethod();
%>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
如何获得所需的输出?