为了账号安全,请及时绑定邮箱和手机立即绑定

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)+"&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 回答

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

contentType前缺了个空格

1 回复 有任何疑惑可以回复我~
#1

柴犬的凝视 提问者

谢谢了
2018-08-08 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
JAVA遇见HTML——JSP篇
  • 参与学习       248282    人
  • 解答问题       3071    个

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

进入课程

JSP页面500错误

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信