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

纵然是瞬间 提交于 2019-12-01 01:21:51

问题


I have a dynamic web project in Eclipse which I run on Glassfish4. In the project, there is an index.jsp file given below. When I run this jsp on the server, I get the error:

org.apache.jasper.JasperException: /index.jsp(1,1) PWC5988: Page directive: illegal to have multiple occurrences of 'contentType' with different values (old: text/html, new: text/html; charset=ISO-8859-1)

This is an internal server error with the description - The server encountered an internal error that prevented it from fulfilling this request.

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="css/designs.css">
</head>
<body>

Content

</body>
</html>

I looked in google and other sites, but found no working solution. The server log stack trace also did not help. Please help me.


回答1:


The issue is that you have "Content-Type" declared twice (as "text/html"). This against specifications and is causing your website to throw an error.

You just can't use both tags simultaneously. The HTTP protocol also provides the Content-Type encoding. So unless you know how your website is serving those pages, don't mess with Content-Type.



来源:https://stackoverflow.com/questions/24743585/error-illegal-to-have-multiple-occurrences-of-contenttype-with-different-val

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!