Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby-on-rails-4/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从POST方法使用ftl显示列表_Java_Spring Mvc_Freemarker_Cuba Platform - Fatal编程技术网

Java 从POST方法使用ftl显示列表

Java 从POST方法使用ftl显示列表,java,spring-mvc,freemarker,cuba-platform,Java,Spring Mvc,Freemarker,Cuba Platform,对不起我的英语! 我不熟悉Spring和FTL。 我想使用显示firstName和lastName,因此,如果有人感兴趣,我将在此处发布我的解决方案: @RequestMapping(value = "/allPersons", method = RequestMethod.GET) public String getPersons(Model model) { LoadContext loadJohn = new LoadContext(John.class)

对不起我的英语! 我不熟悉Spring和FTL。
我想使用
显示
firstName
lastName
,因此,如果有人感兴趣,我将在此处发布我的解决方案:

 @RequestMapping(value = "/allPersons", method = RequestMethod.GET)
    public String getPersons(Model model) {
            LoadContext loadJohn = new LoadContext(John.class);
            loadJohn.setQueryString("select u from test6$John u");
            model.addAttribute("users", dataService.loadList(loadJohn));
            return "list";
    }
ftl应该是这样的: 接下来我面临的问题是我不知道我必须检查列表是否为空<强>!“”这样做吗

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h3>Person List</h3>
<a href="/app-portal/add">Add Person</a>
<br><br>
<div>
    <table border="1">
        <tr>
            <th>First Name</th>
            <th>Last Name</th>
        </tr>
        <#list users as show>
            <tr>
                <td>${show.firstName!""}</td>
                <td>${show.lastName!""}</td>
            </tr>
        </#list>
    </table>
</div>
</body>
</html>

标题
人员名单


名字 姓 ${show.firstName!”“} ${show.lastName!”“}
我希望这将有助于像我这样的人。 此外,如果有人知道如何删除和更新数据,请共享。
谢谢

因此,如果有人感兴趣,我将在这里发布我的解决方案:

 @RequestMapping(value = "/allPersons", method = RequestMethod.GET)
    public String getPersons(Model model) {
            LoadContext loadJohn = new LoadContext(John.class);
            loadJohn.setQueryString("select u from test6$John u");
            model.addAttribute("users", dataService.loadList(loadJohn));
            return "list";
    }
ftl应该是这样的: 接下来我面临的问题是我不知道我必须检查列表是否为空<强>!“”这样做吗

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h3>Person List</h3>
<a href="/app-portal/add">Add Person</a>
<br><br>
<div>
    <table border="1">
        <tr>
            <th>First Name</th>
            <th>Last Name</th>
        </tr>
        <#list users as show>
            <tr>
                <td>${show.firstName!""}</td>
                <td>${show.lastName!""}</td>
            </tr>
        </#list>
    </table>
</div>
</body>
</html>

标题
人员名单


名字 姓 ${show.firstName!”“} ${show.lastName!”“}
我希望这将有助于像我这样的人。 此外,如果有人知道如何删除和更新数据,请共享。
谢谢

看看这里,你能添加一个json的例子吗?@Fjordo我不使用json,只使用springmvc、ftl、cuba的实体,pojos@Fjordo我查看了这些文档,正如我上面提到的,我无法识别我的spring POST方法中的#list的序列。请看这里,你能添加一个json示例吗?@Fjordo我不使用json,只使用springmvc、ftl、cuba的实体, pojos@Fjordo我查看了这些文档,正如我上面提到的,在我的spring POST方法中,我无法识别#list的序列