illegal to have multiple occurrences of contentType with different values

参考:https://blog.csdn.net/vincent_yuan1991/article/details/52814958


在一个项目jsp文件中包含了另一个jsp文件(<%@include file="/back/common/page.jsp"%>),执行出现如下错误:
 
HTTP Status 500 - /back/maint/relogin.jsp(1,2) Page directive: illegal to have multiple occurrences of contentType with different values (old: text/html;charset=GBK, new: text/html;charset=UTF-8)

type Exception report

message /back/maint/relogin.jsp(1,2) Page directive: illegal to have multiple occurrences of contentType with different values (old: text/html;charset=GBK, new: text/html;charset=UTF-8)

description The server encountered an internal error that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: /back/maint/relogin.jsp(1,2) Page directive: illegal to have multiple occurrences of contentType with different values (old: text/html;charset=GBK, new: text/html;charset=UTF-8)
	org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
	org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
	org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:236)
	org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:132)
	org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:608)
	org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
	org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
	org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
	org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
	org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
	org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
	org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:99)
	org.apache.jasper.compiler.Node$IncludeDirective.accept(Node.java:656)
	org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
	org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
	org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
	org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
	org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
	org.apache.jasper.compiler.Validator.validateDirectives(Validator.java:1745)
	org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:182)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:354)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:334)
	org.apache.jasper.compiler.Compiler.compile(Compiler.java:321)
	org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
	org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:328)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:321)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
	emed.base.Portal.toNextPage(Portal.java:148)
	emed.base.Portal.doServlet(Portal.java:106)
	emed.base.Portal.doPost(Portal.java:57)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:643)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
	common.tools.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:26)

主要的错误信息如下: 
Page directive: illegal to have multiple occurrences of contentType with different values (old: text/html;charset=GBK, new: text/html;charset=UTF-8)
意思就是两个位置的charset设置不一致,看了代码之后发现,一个JSP页面了另一个JSP页面(<%@include file="/back/common/page.jsp"%>)。包含页面与被包含页面的@page指令里面的contentType不一致。分别是:
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page contentType="text/html;charset=GBK"%>

解决方案:将两个Jsp文件中page指令的contentType改成一致的就可以了。

<%@ page contentType="text/html;charset=UTF-8"%>
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值