JSP新手,要求帮助,十分感谢
刚开始学习JSP,照书上编写第一个JSP小程,结果就运行不成功。请大家帮助看看,是什么原因?路过各位大侠,多谢了!
<%@ page import= "java.util.* " %>
<%@ page import= "java.math.* " %>
<%@ page import= "java.lang.* " %>
<htmL>
<head><title>MY first JSP</title></head>
<body>
<%! int angles[]={0,30,45,75,90};%>
<TABLE BORDER="2" ALIGN="center">
<th>angel</th><th>sine of angle</th>
<%for(int i=0;i<5;i++)%>
<tr><td><%=angles[i]%></td>
<td><%=Math.sin(Math.toRadians(angles[i]))%></td>
</tr>
</table>
</body>
</html>
上面是代码,下面是浏览器页面上的错误提示:
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: 11 in the jsp file: /1.jsp
i
cannot be resolved to a variable
8: <TABLE BORDER="2" ALIGN="center">
9: <th>angel</th><th>sine of angle</th>
10: <%for(int i=0;i<5;i++)%>
11: <tr><td><%=angles[i]%></td>
12: <td><%=Math.sin(Math.toRadians(angles[i]))%></td>
13: </tr>
14: </table>
An error occurred at line: 12 in the jsp file: /1.jsp
i cannot be resolved to a variable
9: <th>angel</th><th>sine of angle</th>
10: <%for(int i=0;i<5;i++)%>
11: <tr><td><%=angles[i]%></td>
12: <td><%=Math.sin(Math.toRadians(angles[i]))%></td>
13: </tr>
14: </table>
15: </body>
Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:646)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:357)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.23 logs.
------解决方案--------------------
<%for(int i=0;i<5;i++)%>改为<%for(int i=0;i<5;i++){%>,
</tr>后面加上<%}%>
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.aiyiweb.com/java-web/317.html
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.aiyiweb.com/j2ee/2308.html