Hi!
hier sind meine Deps:
Hier ist meine org/example/Main.java (Server):
Hier ist meine resources/index.vm (Velocity-Template):
Wie kriege ich denn jetzt 9 und 7 als Daten in Column 1 und 8 und 6 in Column 2?
Vielen Dank vorab.
hier sind meine Deps:
JSON:
dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-api:5.8.1"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.8.1"
implementation "com.sparkjava:spark-core:2.9.4"
implementation "com.sparkjava:spark-template-velocity:2.7.1"
implementation "org.xerial:sqlite-jdbc:3.42.0.0"
}
Hier ist meine org/example/Main.java (Server):
Java:
package org.example;
import static spark.Spark.*;
import java.util.HashMap;
import java.util.Map;
import spark.ModelAndView;
import spark.template.velocity.VelocityTemplateEngine;
public class Main {
public static void main(String[] args) {
System.out.println("Hello world!");
get(
"/",
(req, res) -> {
Map<String, Object> model = new HashMap<>();
model.put(
"daten",
new Integer[][] {
{9, 8},
{7, 6},
});
return render(model, "index.vm");
});
}
// declare this in a util-class
public static String render(Map<String, Object> model, String templatePath) {
return new VelocityTemplateEngine().render(new ModelAndView(model, templatePath));
}
}
Hier ist meine resources/index.vm (Velocity-Template):
HTML:
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8" />
<title>Page Title</title>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<script
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.0/jquery.min.js"
integrity="sha512-3gJwYpMe3QewGELv8k/BX9vcqhryRdzRMxVfq6ngyWXwo03GFEzjsUm8Q7RZcHPHksttq7/GFoxjCVUjkjvPdw=="
crossorigin="anonymous"
referrerpolicy="no-referrer"
></script>
<link rel="stylesheet" href="https://cdn.datatables.net/1.13.6/css/jquery.dataTables.min.css" />
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<body>
<div class="">
<h3>This is a Heading</h3>
<table id="myTable" class="display">
<thead>
<tr>
<th>Column 1</th>
<th>Column 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Row 1 Data 1</td>
<td>Row 1 Data 2</td>
</tr>
<tr>
<td>Row 2 Data 1</td>
<td>Row 2 Data 2</td>
</tr>
</tbody>
</table>
</div>
<script type="module">
$(document).ready(function () {
let table = new DataTable("#myTable", {
responsive: true,
});
});
</script>
</body>
</html>
Wie kriege ich denn jetzt 9 und 7 als Daten in Column 1 und 8 und 6 in Column 2?
Vielen Dank vorab.