JSP页面500错误

来源:2-12 阶段项目

柴犬的凝视

2018-08-07 20:30

<%@ 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)+"&nbsp;&nbsp;&nbsp;&nbsp;";

}

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)+"&nbsp;&nbsp;&nbsp;&nbsp;");

}

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.


Apache Tomcat/7.0.90


写回答 关注

1回答

  • 慕妹7033251
    2018-08-07 21:29:33
    已采纳

    <%@ page language="java" import="java.util.*"contentType="text/html; charset=utf-8"%>

    contentType前缺了个空格

    柴犬的凝视

    谢谢了

    2018-08-08 14:39:11

    共 1 条回复 >

JAVA遇见HTML——JSP篇

Java Web入门级教程JSP,带你轻松的学习JSP基础知识

248279 学习 · 3071 问题

查看课程

相似问题