正在初步自学jsp困惑很多,书上给的程序运行起来很诡异,之前运行过这个程序,开始不能运行,后来可以运行了,但是今天Tomcat出错,最后换了端口好了,程序在运行时又不能运行了。程序应该没有错,因为之前这样运行过。我没有用eclipse用的是纪事本存的程序,我就不明白了,为什么会有错,望好心人指点。
//02_23.jsp
<html>
<head>
<title>一个useBean动作的例子</title>
</head>
<%@ page contentType="text/html;charset=GB2312" %>
<body>
<center>
<h2>
这是一个使用useBean动作的例子
</h2>
</center>
<jsp:useBean id="test" class="BeanExample.SimpleBean" scope="page"/>
<% test.setString("This is a useBean Action example"); %>
<p>
<h3>
<%=test.displayString()%>
</h3>
</p>
</body>
</html> //SimpleBean.java
package BeanExample;public class SimpleBean
{
String str="";
public SimpleBean()
{
str="This is the inital string";
}
public void setString(String str1)
{
str="Hello! "+str1;
}
public String displayString()
{
return str;
}
}我将生成的class文件,连同文件夹BeanExample存到了……/ROOT\WEB-INF\classes。
//02_23.jsp
<html>
<head>
<title>一个useBean动作的例子</title>
</head>
<%@ page contentType="text/html;charset=GB2312" %>
<body>
<center>
<h2>
这是一个使用useBean动作的例子
</h2>
</center>
<jsp:useBean id="test" class="BeanExample.SimpleBean" scope="page"/>
<% test.setString("This is a useBean Action example"); %>
<p>
<h3>
<%=test.displayString()%>
</h3>
</p>
</body>
</html> //SimpleBean.java
package BeanExample;public class SimpleBean
{
String str="";
public SimpleBean()
{
str="This is the inital string";
}
public void setString(String str1)
{
str="Hello! "+str1;
}
public String displayString()
{
return str;
}
}我将生成的class文件,连同文件夹BeanExample存到了……/ROOT\WEB-INF\classes。
这句话应该放在第一行
还有你没有清空缓存