I was designing a website for academic purposes, but I came across a display error. My html / jsp pages are not displaying the accented texts correctly when retrieving from the database. All are UTF-8 charset in the meta tag and lang pt-br in the html tag. The database I use is MySQL 5.7. Both to insert and display in the mysql shell, accents are displayed correctly. The problem occurs when I enter or edit a record via the html / jsp page, there, whether it is displaying on the page or in the shell, the characters are buggy.
Example of a line:
Alessandro sà £ o raimundo No email 000012341234 07/17/1990
Within a form of a .jsp, I change a contact by sending the parameters to a ServletController that sends it to a class that executes the logic.
public class AlteraContatoLogic implements Logica {
@Override
public Pagina run(HttpServletRequest request, HttpServletResponse response) throws Exception {
// buscando os parâmetros no request
long id = Long.parseLong(request.getParameter("id"));
String nome = request.getParameter("nome");
//String endereco = new String(request.getParameter("endereco").getBytes("UTF-8"));
String endereco = request.getParameter("endereco");
String email = request.getParameter("email");
String telefone = request.getParameter("telefone");
String dataEmTexto = request.getParameter("dataNascimento");
Calendar dataNascimento = null;
// fazendo a conversão da data
try {
Date date = sdf_dmy.parse(dataEmTexto);
dataNascimento = Calendar.getInstance();
dataNascimento.setTime(date);
} catch (ParseException e) {
throw new ServletException(e);
}
// monta um objeto contato
Contato contato = new Contato();
contato.setNome(nome);
contato.setEndereco(endereco);
contato.setEmail(email);
contato.setDataNascimento(dataNascimento);
contato.setTelefone(telefone);
contato.setId(id);
// altera no bd
new ContatoDao().set(contato);
return new Redirecionador(request, response, "./");
}
}
Does anyone know what it can be and how to solve it? Thank you in advance.