1. 程式人生 > >illegal to have multiple occurrences of 'contentType' with different values

illegal to have multiple occurrences of 'contentType' with different values

springboot專案,開啟jsp提示如下錯誤: illegal to have multiple occurrences of ‘contentType’ with different values(old: [text/html;charset=UTF-8], new: [text/html; charset=UTF-8])

global.jsp檔案(一個全域性的標籤庫檔案)

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

page1.jsp檔案

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <%@ include file="/common/global.jsp"%>

原因分析: page1.jsp引入了global.jsp,注意global.jsp標籤中charset前面位置有空格,而page1.jsp相同位置無空格,兩者對比不同,所有報錯

contentType=”text/html; charset=UTF-8”
contentType=”text/html;charset=UTF-8”

解決辦法: 兩者設定相同格式,要麼在charset前都帶空格,要麼都不帶空格