错误 - 多次出现具有不同值的'contentType'是非法的 [英] Error - illegal to have multiple occurrences of 'contentType' with different values

查看:969
本文介绍了错误 - 多次出现具有不同值的'contentType'是非法的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Eclipse中有一个动态Web项目,我在Glassfish4上运行。在项目中,有一个index.jsp文件,如下所示。当我在服务器上运行这个jsp时,我收到错误:

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:页面指令:非常多次出现具有不同值的'contentType'(旧: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.

推荐答案

问题是你有两次声明Content-Type(如text / html) 。这违反了规范,导致您的网站出错。

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.

您不能同时使用这两个标签。 HTTP协议还提供Content-Type编码。因此,除非您知道您的网站如何为这些网页提供服务,否则请不要使用Content-Type。

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.

这篇关于错误 - 多次出现具有不同值的'contentType'是非法的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆