1

I am in trouble with turkişh character on html5. I investigated same issues on web and I applied solutions but it doesn't works. I share my codes. Could you help me please?

here is my allemployees.html file :

<!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>

and here is my jsp file(I include the html):

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../templates/allemployees.html" %>
luffy
  • 315
  • 1
  • 4
  • 22

1 Answers1

3

You can use import with charEncoding attribute in JSTL core lib.

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

EDIT

If you put html files into WEB-INF/templates then you should use mapping

xml:

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

annotation: add addResourceHandlers method in Config class

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

so, you can access html file in WEB-INF folder like this:

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

Gurkan Yesilyurt
  • 2,635
  • 2
  • 20
  • 21
  • I tried this but Spring MVC give this error No mapping found for HTTP request with URI [/sample/WEB-INF/templates/allemployees.html] – luffy May 03 '17 at 12:53
  • edited answer @luffy, web-inf folder isn't accessed directly. – Gurkan Yesilyurt May 03 '17 at 13:29
  • thank you but I use Spring 4 MVC I didn't use xml for configurations I handle it anotation. So do you know how to handle this on anotation? – luffy May 03 '17 at 13:35
  • I investigated your edited. I want to ask one thing. My template directory under the webapp/resources directory and jsp page under the WEB-INF/pages. I added webapp/resources directory to Resource Handler. And I tried your solution but I failed. Spring give an error no mapping found for allemployees.html. – luffy May 04 '17 at 07:12
  • @luffy for /webapp/resources/template/allempoyees.html, try addResourceHandler("/resources/**").addResourceLocations("/resource/") and url="/resources/templates/allemployees.html". And You can use this for other static files too, e.g href="" will map your bootstrap file. – Gurkan Yesilyurt May 04 '17 at 09:30
  • yes it work's for html and turkish character and I clicked your answer thank you so much. but now I can not include bootstrap files to allemployees.html. I did like you said " rel="stylesheet"> on allemployees.html tags but it doesn't work. – luffy May 04 '17 at 10:47
  • @luffy sorry, I think you use bootstrap in JSP head tag, you cannot use JSTL (c:url etc.) in plain html but JSP. – Gurkan Yesilyurt May 04 '17 at 11:05
  • 1
    Ok I got it. I'll try this. – luffy May 04 '17 at 11:10