html5文件没有正确显示土耳其字符

时间:2017-05-03 12:04:56

标签: html5 jsp turkish

我在html5上遇到turkişh字符有问题。我在网上调查了同样的问题,我应用了解决方案,但它不起作用。我分享我的代码。你能帮帮我吗?

这是我的allemployees.html文件:

<!DOCTYPE html>
<html lang="tr">
<head>
<meta charset="UTF-8">
<link href="<c:url value="../resources/css/bootstrap.css" />"    rel="stylesheet">
<link href="<c:url value="../resources/css/bootstrap-theme.css" />" rel="stylesheet">
</head>
<body>
<div class="table-responsive">
<h2>Tüm Çalışanlar</h2>
<table class="table table-bordered">
<div class="row">
<div class="col-md-12">
<tr>
<td class="field-label col-xs-3 active">
<label>TC No</label>
</td>
<td class="field-label col-xs-3 active">
<label>Ad</label>
</td>
<td class="field-label col-xs-3 active">
<label>Soyad</label>
</td>
<td class="field-label col-xs-3 active">
<label>Başlama Tarihi</label>
</td>
<td class="field-label col-xs-3 active">
<label>Maaş</label>
</td>
</tr>
</div>
</div>
<c:forEach items="$(allEmployees)" var="employee">
<tr>
<div class="row">
<div class="col-md-12">
<td>$(employee.citizenNumber)</td>
<td>$(employee.name)</td>
<td>$(employee.surname)</td>
<td>$(employee.joiningDate)</td>
<td>$(employee.salary)</td>
<td>
<a href="<c:url value='/edit-${employee.oid}-employee' />">${employee.oid}</a>
</td>
<td>
<a href="<c:url value='/delete-${employee.oid}-employee' />">delete</a>
</td>
</div>
</div>
</tr>
</c:forEach>
</table>
</div>
<br/>
<a href="<c:url value='/new' />">Yeni Çalışan</a>
</body>
</html>

这是我的jsp文件(我包含了html):

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../templates/allemployees.html" %>

1 个答案:

答案 0 :(得分:3)

您可以在JSTL核心库中使用import charEncoding属性。

<c:import url="../templates/allemployees.html" charEncoding="UTF-8" />

修改

如果您将html文件放入 WEB-INF / templates ,那么您应该使用映射

<强> XML

<mvc:resources mapping="/templates/**" location="/WEB-INF/templates/"  />

注释:在Config类中添加addResourceHandlers方法

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
   registry.addResourceHandler("/templates/**").addResourceLocations("/WEB-INF/templates/");
}

所以,您可以访问WEB-INF文件夹中的html文件,如下所示:

<c:import url="/templates/allemployees.html" charEncoding="UTF-8" />