Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

276
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda