摘要:本文主要向大家介绍了JAVA语言之JavaEE异常Page directive: illegal to have multiple occurrences of contentType with different value的解决办法,通过具体的内容向大家展示,希望对大家学习JAVA语言有所帮助。
本文主要向大家介绍了JAVA语言之JavaEE异常Page directive: illegal to have multiple occurrences of contentType with different value的解决办法,通过具体的内容向大家展示,希望对大家学习JAVA语言有所帮助。
异常描述:
Page directive: illegal to have multiple occurrences of contentType with different values (old: text/html; charset=utf-8, new: text/html; charset = UTF-8)] with root cause
org.apache.jasper.JasperException: /Hello.txt (line: 1, column: 2) Page directive: illegal to have multiple occurrences of contentType with different values (old: text/html; charset=utf-8, new: text/html; charset = UTF-8)
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:41)
今晚敲着一个Include指令练习,结果丢出了这个异常,看看代码,也没看出啥毛病。
DisplayText.jsp
<span style="font-size:16px;"><%@ page contentType = "text/html; charset=utf-8" %>
<%@ page pageEncoding="utf-8" %>
<html>
<head>
<title>DisplayText</title>
</head>
<body>
<H3><%@ include file = "Hello.txt" %> </H3>
</body>
</html></span>
Hello.txt
<span style="font-size:16px;"><%@ page contentType = "text/html; charset = UTF-8" %>
<%@ page pageEncoding="utf-8" %>
您好!
how are you?</span>
上网查了一下再仔细看了一下异常的描述,发现是
DisplayText.jsp中的
<span style="font-family:SimSun;font-size:16px;"><%@ page contentType = "text/html; charset=utf-8" %></span>
和Hello.txt中的
<%@ page contentType = "text/html; charset = UTF-8" %>
contentType 描述不一致导致的,不仅utf-8大小写需要统一,连空格的数目也要一样(例如=两边的空格)!复制粘贴过去,运行通过了。
本文由职坐标整理并发布,希望对同学们有所帮助。了解更多详情请关注编程语言JAVA频道!
您输入的评论内容中包含违禁敏感词
我知道了
请输入正确的手机号码
请输入正确的验证码
您今天的短信下发次数太多了,明天再试试吧!
我们会在第一时间安排职业规划师联系您!
您也可以联系我们的职业规划师咨询:
版权所有 职坐标-一站式IT培训就业服务领导者 沪ICP备13042190号-4
上海海同信息科技有限公司 Copyright ©2015 www.zhizuobiao.com,All Rights Reserved.
沪公网安备 31011502005948号