帮我解决个小问题啊
我装的是jdk 1.6.0_18,tomcat6,
我做了个jsp,代码如下:
<%@ page contentType="text/html;charset=utf-8" %>
<!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=utf-8" />
<title>ex4-4</title>
</head>
<body>
<%! int num = 0;
void countnum() {
num++;
}
%>
<% countnum(); %>
<h3>变量num的值现在为:</h3>
<br/>
<br/>
<h1><% =num; %></h1>
</body>
</html>
结果运行有问题:
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP:
An error occurred at line: 13 in the jsp file: /ex4-4.jsp
Syntax error, insert ";" to complete BlockStatements
10:
11: <%! int num = 0;
12: void countnum() {
13: num++
14: }
15: %>
16: <% countnum(); %>
An error occurred at line: 16 in the jsp file: /ex4-4.jsp
Syntax error on token ";", Expression expected after this token
13: num++
14: }
15: %>
16: <% countnum(); %>
17: <h3>鍙橀噺num鐨勫�鐜板湪涓猴細</h3>
18: <br/>
19: <br/>
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:439)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:312)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:299)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:589)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.24 logs.
Apache Tomcat/6.0.24
请大家帮我看看到底我哪里出错了?
如果jsp部分全部写在一块,是能正确运行的。