mercredi 1 janvier 2020

How to show on the web json

I'm using java spring boot i can print json result on the terminal but i want to show on the web so how can i change this code it to show on web

package com.tutorial.springboot;

import com.google.gson.Gson;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.SimpleDriverDataSource;
import lombok.var;
import java.io.FileInputStream;
import java.io.IOException;

import java.util.List;
import java.util.Map;
import java.util.Properties;


import java.sql.Driver;



public class Application {
    public static void main(String[] args) throws IOException, ClassNotFoundException{

        var prop = new Properties();
        prop.load(new FileInputStream("src/main/resources/Application.properties"));
        var ds = new SimpleDriverDataSource();

        ds.setDriverClass(((Class<Driver>) Class.forName(prop.getProperty("jdbc.driver"))));
        ds.setUrl(prop.getProperty("jdbc.url"));
        ds.setUsername(prop.getProperty("jdbc.username"));
        ds.setPassword(prop.getProperty("jdbc.password"));

        var sql = "SELECT * FROM ked_evaluation_data";

        var jtm = new JdbcTemplate(ds);
        List<Map<String, Object>> rows = (List<Map<String, Object>>) jtm.queryForList(sql);

        Gson gson = new Gson();
        String jcart=gson.toJson(rows);
        System.out.println(jcart);
        //rows.forEach(System.out::println);
    }
}

In summary, i want to know how to change the code to show the result on web If someone knows that please teach me!! thank you!




Aucun commentaire:

Enregistrer un commentaire