How to write a values in HTML template, Using Microservices?

MVC Pattern template creation for PDF conversion

public static void main(String...aArguments) throws IOException {

        String strDatos = "Jorman 14988611";
    StringTokenizer tokens = new StringTokenizer(strDatos, " ");
    int nDatos = tokens.countTokens();
    String[] datos = new String[nDatos];
    int i = 0;

    


This code separates a string into tokens and stores them in an array of strings, and then compares a variable with the first home ... why isn't it working?

>Solution :

home.jsp:
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
    <title>View Names</title>
    <link href="<c:url value="/css1/common1.css"/>" rel="stylesheet" type="text/css">
</head>
<body>
<table>
    <thead>
    <tr>
        <th>Name</th>
        <th>Name</th>
        <th>Name</th>
    </tr>
    </thead>
    <tbody>



    <c:forEach items="${names}" var="name">
        <tr>
            <td>${name}</td>
        ${name1}
        </tr>
    </c:forEach>
    </tbody>
</table>
</body>
</html>


Note: here "names" refer List<String> . If you have List<User> then in <td> <td>${user.getName()}</td> 

mapping:

    @PostMapping("/view")
    public String getModel(@RequestBody ViewModel viewModel, Model model){

        model.addAttribute("names", viewModel.getNames());
        model.addAttribute("name1", viewModel.getName1());
        return "home";
}

Leave a Reply