解决Page directive: illegal to have multiple occurrences of contentType with different values错误

一个jsp页面包含另一个jsp页面忽然出现这种错误

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)
    at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:275)
    at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:107)
    at org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:135)
    at org.apache.jasper.compiler.Node$PageDirective.accept(Node.java:571)
    at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
    at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
    at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
    at org.apache.jasper.compiler.Node$Root.accept(Node.java:464)
    at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
    at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
    at org.apache.jasper.compiler.Validator$DirectiveVisitor.visit(Validator.java:101)
    at org.apache.jasper.compiler.Node$IncludeDirective.accept(Node.java:635)
    at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2376)
    at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2428)
    at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2434)
    at org.apache.jasper.compiler.Node$Root.accept(Node.java:464)

首先看下此两个页面中page指令

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

charset=UTF-8 字符集是否不同。大小写不同也会报错。所以保持统一。两个页面的字符集设置成一模一样。要么同时大写要么同时小写

猜你喜欢

转载自blog.csdn.net/saygood999/article/details/106767020