Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

273
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!