又出错!!!
程序的原意是输出带两位小数的百分数
原代码:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*,java.util.*,java.math.*;" errorPage="" %>
<html>
<head>
<title>邮箱运营</title>
<style type="text/css">
<!--
body {
background-color: #EEEEEE;
}
.style1 {
font-size: 14px;
font-weight: bold;
}
td {
font-size: 12px;
}
-->
</style></head>
<%! String url,user,password,sql,quhao,rongliang,tel,fangshi,shijian,qingkuang;%>
<%! Connection conn;%>
<%! ResultSet rs;%>
<%! Statement stmt;%>
<%! int hezec,hezecbatint;%>
<%! double hezecbat;%>
<%! FormatPercent(int, int);%>
<body>
<%
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mail";
String user="sa";
String password="123456";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
sql="select count(*) as hezecbatint from ruyi where quhao='0530' and tel>'13300000000' and fangshi='bat' and shijian like'2006-9%' ";
rs=stmt.executeQuery(sql);
rs.next();
hezecbatint=rs.getInt("hezecbatint");
sql="select count(*) as hezec from ruyi where quhao='0530' and tel>'13300000000' and shijian like'2006-9%' ";
rs=stmt.executeQuery(sql);
rs.next();
hezec=rs.getInt("hezec");
%>
<%=hezecbatint%>.<%=hezec%>.<%=FormatPercent(hezecbatint/hezec,2)%>
<%
rs.close();
stmt.close();
conn.close();
}catch(Exception e){
out.println(e.toString());
}
%>
</body>
</html>
出错提示:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 25 in the jsp file: /333.jsp
Generated servlet error:
Return type for the method is missing
An error occurred at line: 25 in the jsp file: /333.jsp
Generated servlet error:
Syntax error on token "int", VariableDeclaratorId expected after this token
An error occurred at line: 25 in the jsp file: /333.jsp
Generated servlet error:
Syntax error on token "int", VariableDeclaratorId expected after this token
An error occurred at line: 44 in the jsp file: /333.jsp
Generated servlet error:
The method FormatPercent(int, int) is undefined for the type _333_jsp
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)