<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<%@ page import="Bean1" %>
<!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>
<jsp:useBean id="Bean1Test" scope="session" class="Bean1" />
<%Bean1Test.setName("dpf");%>
<%=Bean1Test.getName()%>
</body>
</html>如何什么会出现这个错误:
Generated servlet error:
C:\Tomcat5.0\work\Catalina\localhost\howjsp\org\apache\jsp\test2_jsp.java:7: 需要 '.'
import Bean1;
<%@ page import="Bean1" %>
<!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>
<jsp:useBean id="Bean1Test" scope="session" class="Bean1" />
<%Bean1Test.setName("dpf");%>
<%=Bean1Test.getName()%>
</body>
</html>如何什么会出现这个错误:
Generated servlet error:
C:\Tomcat5.0\work\Catalina\localhost\howjsp\org\apache\jsp\test2_jsp.java:7: 需要 '.'
import Bean1;
import java.awt.*;
import java.util.*;public class Bean1{
private String name=new String();
public Bean1() {
}
public void setName(String name){
this.name=name;
}
public String getName(){
return name;
}
}
<%@ page import="Bean1" %>
去掉就可以运行了,应该就是这个问题吧。
我也是初学者,我用bean的时候都没有用IMPORT都成功的,书上也都不用那句话的
然后JSP页面的<jsp:useBean id="Bean1Test" scope="session" class="Bean1" />改成了
<jsp:useBean id="Bean1Test" scope="session" class="test.Bean1" />
我也是初学的,也不知道为什么要加个package才可以正常运行。