0

我想用jsp写一个计数器。这是我的代码:

Countinghilfe.java:

package Counting;
import java.io.*;
import java.util.*;

public class Countinghilfe{

public static int getCount(){
String s="";
try {
BufferedReader in = new BufferedReader(new FileReader("Anzahl.txt"));
s=in.readLine();


} catch (IOException e) {
    e.printStackTrace();
}
Integer zahl=new Integer(s);
return zahl;
}

public static void increase(){

String s="";
try {
BufferedReader in = new BufferedReader(new FileReader("Anzahl.txt"));
s=in.readLine();
Integer zahl=new Integer(s);
zahl++;
BufferedWriter output=new BufferedWriter(new FileWriter("Anzahl.txt"));
output.write(String.valueOf(zahl));
output.close();
 } catch (IOException e) {
    e.printStackTrace();
}
}   
 }    

在 counter.jsp 文件中:

<html>
<head>
<title>Counter</title>
</head>
<body>
<%@ page import="Counting.Countinghilfe" %>
<%
Countinghilfe cl = new Countinghilfe();
out.println("<h2>Sie sind der ");
out.println( cl.getCount());
out.println(". Besucher auf unserer Site!</h2>");
cl.increase();
%>
</body>
</html>

显示的错误是:org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to load class for JSP。还有这些:

org.apache.jasper.JasperException: Unable to compile class for JSP: An error occurred at line: 6 in the generated java file 只能导入一个类型。Counting.Countinghilfe 解析为一个包

Countinghilfe 无法解析为类型

我该如何解决这个问题?

4

0 回答 0