JSP页面500错误
<%@ page language="java" import="java.util.*"contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Insert title here</title>
</head>
<body>
<%!
//返回九九乘法表对应的HTML代码,通过表达式来调用,在页面上显示
String printMultiTable1()
{
String s="";
for(int i=1;i<=9;i++)
{
for(int j=1;j<=i;j++)
{
s+=i+"*"+j+"="+(i*j)+" ";
}
s+="<br>";//追加换行标签
}
return s;
}
//JSP内置对象out对象,使用脚本方式调用,打印九九乘法表
void printMultiTable2(JspWriter out) throws Exception
{
for(int i=1;i<=9;i++)
{
for(int j=1;j<=i;j++)
{
out.println(i+"*"+j+"="+(i*j)+" ");
}
out.println("<br>");//追加换行标签
}
}
%>
<h1>九九乘法表</h1>
<hr>
<%=printMultiTable1() %>
<br>
<% printMultiTable2(out);%>
</body>
</html>
错误页面
HTTP Status 500 – Internal Server Error
Type Exception Report
Message /exercise.jsp (line: 1, column: 84) The JSP specification requires that an attribute name is preceded by whitespace
Description The server encountered an unexpected condition that prevented it from fulfilling the request.
Exception
org.apache.jasper.JasperException: /exercise.jsp (line: 1, column: 84) The JSP specification requires that an attribute name is preceded by whitespace org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:443) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:89) org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:164) org.apache.jasper.compiler.Parser.parseAttributes(Parser.java:183) org.apache.jasper.compiler.ParserController.getPageEncodingForJspSyntax(ParserController.java:479) org.apache.jasper.compiler.ParserController.determineSyntaxAndEncoding(ParserController.java:420) org.apache.jasper.compiler.ParserController.doParse(ParserController.java:190) org.apache.jasper.compiler.ParserController.parseDirectives(ParserController.java:119) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:194) org.apache.jasper.compiler.Compiler.compile(Compiler.java:374) org.apache.jasper.compiler.Compiler.compile(Compiler.java:354) org.apache.jasper.compiler.Compiler.compile(Compiler.java:341) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:660) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:364) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339) javax.servlet.http.HttpServlet.service(HttpServlet.java:731) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
Note The full stack trace of the root cause is available in the server logs.