jsp 如何调用java类 初学
现有test.javapackagetest;publicclassTest1{publicStrings="welcometojava1.";publicStrings...
现有test.java
package test;
public class Test1 {
public String s="welcome to java1.";
public String s(){
return (s);}
}
编译为Test1.class
jsp文件test.jsp调用Test1
<%@ page language="java" import="java.io.*, java.sql.*,javax.sql.*, java.util.* " pageEncoding="ISO-8859-1"%>
<%@ page import="test.Test1"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<%
Test1 aa=new Test1();
out.println(aa.s());
%>
</body>
</html>
出错
找不到类文件
哪位高手指点一下小可是哪出问题了?
文件结购:
D:\hwy
————WEB-INF\classes\test\Test1.class
————test.jsp 展开
package test;
public class Test1 {
public String s="welcome to java1.";
public String s(){
return (s);}
}
编译为Test1.class
jsp文件test.jsp调用Test1
<%@ page language="java" import="java.io.*, java.sql.*,javax.sql.*, java.util.* " pageEncoding="ISO-8859-1"%>
<%@ page import="test.Test1"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<body>
<%
Test1 aa=new Test1();
out.println(aa.s());
%>
</body>
</html>
出错
找不到类文件
哪位高手指点一下小可是哪出问题了?
文件结购:
D:\hwy
————WEB-INF\classes\test\Test1.class
————test.jsp 展开
6个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询