In my HTML I get this STRING 'Destro' and step into that JS sendPost ()
<tr>
<td>Destros</td>
<td><span class="label label-success">${analitico.vitoriasDestro}</span></td>
<td><span class="label label-danger">${analitico.derrotasDestro}</span></td>
<td><span>${analitico.totalDestroPercent}%</span></td>
<td><span class="statusPercent"><a style="display:none">${analitico.totalDestroPercent}</a></span></td>
<td><a href="#" onclick="sendPost('relatorio-analitico-a', {id: 'Destro'});"><i class="dripicons-folder-open"></i></a></td>
</tr>
In my JS I should get this STRING 'Destro' and do the post
if (!window.sendPost) {
window.sendPost = function (url, obj) {
//Define o formulário
var myForm = document.createElement("form");
myForm.action = url;
myForm.method = "post";
for (var key in obj) {
var input = document.createElement("input");
input.type = "text";
input.value = obj[key];
input.name = key;
myForm.appendChild(input);
}
//Adiciona o form ao corpo do documento
document.body.appendChild(myForm);
//Envia o formulário
myForm.submit();
};}
But the String is arriving in my controller with no value 'NULL'
public ModelAndView analiticoViewA(String receive, HttpSession session, HttpServletRequest request) {
try {
UsuarioDTO usuario = (UsuarioDTO) request.getSession().getAttribute("usuarioLogado");
analiticoDTO.setIdAnalitico(usuario.getIdUsuario());
usuarioDTO.setIdUsuario(usuario.getIdUsuario());
System.out.println("imprime :" + receive);
List<ResultadoDTO> result = analiticoDAO.selecionaAnalitc(receive, usuario.getIdUsuario());
ModelAndView mv2 = new ModelAndView("relatorio-a");
mv2.addObject("analitico", analiticoDAO.buscaPorId(analiticoDTO));
mv2.addObject("dinamico", result);
mv2.addObject("user", usuarioDAO.buscaPorId(usuarioDTO));
return mv2;
} catch (SQLException e) {
UsuarioDTO usuario = (UsuarioDTO) request.getSession().getAttribute("usuarioLogado");
capturaException.ExceptionHandlingController(e, usuario);
ModelAndView mv = new ModelAndView("error-pages/erro-500");
return mv;
}
}
Note: There is no error in the console.
I think I should be doing something wrong in JS if someone can visualize something.