Galera seguir todos os passos do instrutor em relação ao encolding mas ainda estou com problemas... Estou usando o banco MYSQL, e o encoding da base de dados é : utf8_general_ci
Minha classe de configuração:
package br.com.capsadr.conf;
import javax.servlet.Filter;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.CharacterEncodingFilter;
import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer;
@Configuration
public class SpringMVCServlet extends AbstractAnnotationConfigDispatcherServletInitializer
{
@Override
protected Class<?>[] getRootConfigClasses(){
return new Class[] { JPAConfiguration.class, AppWebConfiguration.class, AppSecurityConfiguration.class};
}
@Override
protected Class<?>[] getServletConfigClasses()
{
return null;
}
@Override
protected String[] getServletMappings()
{
return new String[] { "/" };
}
@Override
protected Filter[] getServletFilters() {
CharacterEncodingFilter filter = new CharacterEncodingFilter();
filter.setEncoding("UTF-8");
filter.setForceEncoding(true);
filter.setForceRequestEncoding(true);
filter.setForceResponseEncoding(true);
return new Filter[]{filter};
}
}
JSP com problema:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fc"%>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@taglib uri="http://www.springframework.org/security/tags"
prefix="security"%>
<!DOCTYPE html>
<html lang="pt-br">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Cadastro - Usuário</title>
<!-- Bootstrap -->
<link href="<c:url value="/resources/css/bootstrap.min.css"></c:url>"
rel="stylesheet">
<link href="<c:url value="/resources/css/daterangepicker.css"></c:url>"
rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet">
<link href="<c:url value="/resources/css/main.css"></c:url>"
rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<header>
<div class="container">
<div class="row">
<div class="col-md-6">LOGO</div>
<div class="col-md-6">
<nav>
<ul class="nav nav-tabs">
<li role="presentation" class="active"><a href="#">Início</a></li>
<li role="presentation"><a href="#">Perfil</a></li>
<li role="presentation"><a
href="<c:url value="/sair"></c:url>">Sair</a></li>
</ul>
<div class="alert alert-info" role="alert">
<security:authentication property="principal" var="adm" />
<strong>Usuário Logado:</strong> ${adm.username}<br> <strong>Data
Atual:</strong>
<fmt:formatDate value="${horaAtual}" dateStyle="FULL" type="date" />
</div>
</nav>
</div>
</div>
</div>
</header>
<div class="container">
<div class="row">
<div class="col-sm-12 col-md-6">
<span> Quantidade de itens por página:</span>
<select name="qtdItensPagina" id="idQtdItensPagina" class="form-control" style="width: 20%;">
<option value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
</select>
<!-- <div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Ordenar por:</h3>
</div>
<div style="margin: 20px;">
<label class="radio-inline">
<input type="radio"name="radioOptions" id="inlineRadio1" value="nome" checked="checked"> Nome
</label>
<label class="radio-inline">
<input type="radio" name="radioOptions" id="inlineRadio2" value="nuProntuario">Nº Prontuário
</label>
<label class="radio-inline">
<input type="radio"name="radioOptions" id="inlineRadio3" value="nuCartSus">Nº Sus
</label>
<label class="radio-inline">
<input type="radio"name="radioOptions" id="inlineRadio4" value="localArquivo">Localização em arquivo
</label>
</div>
</div> -->
</div>
<div class="col-sm-12 col-md-6">
<a href='<c:url value="/usuarios/novo"></c:url>'
class="btn btn-primary" style="width: 100%;"> <span
class="glyphicon glyphicon-plus-sign" aria-hidden="true"></span>
Novo
</a> <br> <br> <a
href='<c:url value="/usuarios/novo"></c:url>'
class="btn btn-default" style="width: 100%;"> <span
class="glyphicon glyphicon-search" aria-hidden="true"></span>
Consultar
</a>
</div>
</div>
<div class="row">
<div class="col-sm-12 col-md-8">
</div>
</div>
<br> <br> <br>
<div class="row">
<div class="col-sm-12 col-md-12">
<table id="tabelaInicio" class="table table-responsive tablesorter">
<thead>
<tr>
<th>
<span class="glyphicon glyphicon-sort" aria-hidden="true"></span>
Nome do usuário
</th>
<th>
<span class="glyphicon glyphicon-sort" aria-hidden="true"></span>
Nº Prontuário
</th>
<th>
<span class="glyphicon glyphicon-sort" aria-hidden="true"></span>
Nº SUS
</th>
<th>
<span class="glyphicon glyphicon-sort" aria-hidden="true"></span>
Localização em arq.
</th>
<th class="text-center">Editar</th>
<th class="text-center">Visualizar</th>
<th class="text-center">Excluir</th>
</tr>
</thead>
<tbody>
<c:forEach var="usuario" items="${listaUsuario}">
<tr>
<td>${usuario.nome}</td>
<td>${usuario.nuProntuario}</td>
<td>${usuario.nuCartSus}</td>
<td>${usuario.localEmArquivo}</td>
<td class="text-center"><a
href='<c:url value="/usuarios/editar/${usuario.id}"></c:url>'
class="btn btn-primary"> <span
class="glyphicon glyphicon-pencil" aria-hidden="true"></span>
</a></td>
<td class="text-center"><a
href='<c:url value="/usuarios/visualizar/${usuario.id}"></c:url>'
class="btn btn-info"> <span
class="glyphicon glyphicon-eye-open" aria-hidden="true"></span>
</a></td>
<td class="text-center"><a href="#modal${usuario.id}"
class="btn btn-danger"> <span
class="glyphicon glyphicon-trash" aria-hidden="true"></span>
</a></td>
</tr>
</c:forEach>
</tbody>
<tfoot>
</tfoot>
</table>
</div>
</div>
<footer>
<div class="row">
<div class=" col-sm-12 col-md-12 text-center">
<form:form servletRelativeAction="/usuarios" methodParam="GET">
<ul class="pagination pagination-lg">
<li><a href="#" aria-label="Previous"> <span
aria-hidden="true">«</span>
</a></li>
<c:forEach begin="1" end="${fimQtdPaginacao}" varStatus="tam">
<c:if test="${paginaAtivada==tam.index-1}">
<li class="active"><a
href='<c:url value='/usuarios/?qtdItensPagina=${qtdItensPaginaAtual}&pagina=${tam.index-1}'></c:url>'>${tam.index}
<span class="sr-only">(current)</span>
</a></li>
</c:if>
<c:if test="${paginaAtivada!=tam.index-1}">
<li><a
href='<c:url value='/usuarios/?qtdItensPagina=${qtdItensPaginaAtual}&pagina=${tam.index-1}'></c:url>'>${tam.index}
<span class="sr-only">(current)</span>
</a></li>
</c:if>
</c:forEach>
<li><a href="#" aria-label="Next"> <span
aria-hidden="true">»</span>
</a></li>
</ul>
</form:form>
</div>
</div>
</footer>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="<c:url value="/resources/js/jquery-3.1.1.js"></c:url>"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="<c:url value="/resources/js/bootstrap.min.js"></c:url>"></script>
<script src="<c:url value="/resources/js/jquery-latest.js"></c:url>"></script>
<script src="<c:url value="/resources/js/jquery.tablesorter.min.js"></c:url>"></script>
<script src="<c:url value="/resources/js/moment.js"></c:url>"></script>
<script src="<c:url value="/resources/js/daterangepicker.js"></c:url>"></script>
<script src="<c:url value="/resources/js/call_functions.js"></c:url>"></script>
</body>
</html>