Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

277
Visualizações
How to pass parameter from jsp to controller spring mvc

I have a problem passing a parameter (data:image/png;base64 generated from a chart) from jsp (because I generated that dataurl with javascript) to spring controller.

My controller is this:

@ResponseBody
    @RequestMapping(value = "/generateChartImg", method = RequestMethod.GET,produces = "image/jpeg")
    public byte[] generateChartImg(@RequestParam("img") String img){
        final String methodName = "generateChartImg()";
        img = img.replace("data:image/png;base64,", "");
        logger.info("{} - url immagine chart: {}", methodName,img);
        byte[] decodeBase64 = Base64.getDecoder().decode(img.getBytes(StandardCharsets.UTF_8));
        return decodeBase64;
    }

and the jsp is:

    <body>
        <div id="chart" style="width:400px;height:300px;"></div>
        <input type="hidden" id="img" name="img" value="" />
    </body>

and javascript script is:

    <
script type = "text/javascript" >
    var options = {
        series: [44, 55, 13, 43, 22],
        chart: {
            width: 380,
            type: 'pie',
        },
        labels: ['Team A', 'Team B', 'Team C', 'Team D', 'Team E'],
        responsive: [{
            breakpoint: 480,
            options: {
                chart: {
                    width: 200
                },
                legend: {
                    position: 'bottom'
                }
            }
        }]
    };

var chart = new ApexCharts(document.querySelector("#chart"), options);
chart.render().then(() => {
    window.setTimeout(function() {
        chart.dataURI().then((uri) => {
            document.getElementById('img').value = uri;
        })
    }, 1000)
})

I hope someone can help me to figure it out because I just need to get an image generated by apexchart and send to controller so when I call the controller url it shows to me the image. I did a test passing a static dataurl and it works but I want now to generate dataurl and passing it from jsp. THANKS

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda