我正在將舊的和一些新的東西合併到一個Web應用程序中。但是,使用瑞典語字母時,頁面將失敗。它似乎不是一個服務器問題,因爲舊的.jsp頁面將正確加載。具有特殊字符的Facelets頁面導致MalformedByteSequenceException:UTF8Reader.invalidByte中的3字節UTF-8序列的無效字節2
我在xhtml頭文件中丟失了什麼?舊頁的
mar 25, 2015 11:50:53 FM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/BowlingInfo] threw exception
com.sun.org.apache.xerces.internal.impl.io.MalformedByteSequenceException: Invalid byte 2 of 3-byte UTF-8 sequence.
at com.sun.org.apache.xerces.internal.impl.io.UTF8Reader.invalidByte(UTF8Reader.java:691)
<!DOCTYPE html>
<html lang="sv-SE"
xmlns="http://www.w3c.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head>
<link rel="stylesheet" href="bowling-style.css" />
<meta http-equiv="content-type" content="text/html" charset="ISO-8859-1" />
</h:head>
<h:body>
<!-- FAIL -->
<h1>Hallmästaren</h1>
</h:body>
</html>
實施例,將工作
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!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=UTF-8">
<title>Svalövs bowlinghall</title>
<script type="text/JavaScript">
<!--
var currentTime = new Date()
function AutoRefresh(t) {
setTimeout("location.reload(true);", t);
}
function GetServerDate() {
var date = new Date();
dateNow = date;
document.write(dateNow);
return dateNow;
}
</script>
<link rel="stylesheet" type="text/css" href="bowling-style.css" />
</head>
<body onload="JavaScript:AutoRefresh(15000);" bgcolor="C2F2BD">
<f:view>
.........
你的編輯器不保存使用UTF-8的Facelets文件。答案取決於所使用的編輯器。你最好告訴它。在不相關的說明中,爲什麼您將元內容類型標頭從UTF-8更改爲ISO-8859-1?當通過HTTP提供服務時,這不會造成麻煩,但這很簡單。 – BalusC 2015-03-25 10:59:38
我在windows上使用eclipse – user2130951 2015-03-25 11:23:59
將此更改爲UTF-8使其正常工作。 – user2130951 2015-03-25 11:33:33