Thymeleaf 2.1.4官方文档演示了for each如下用法:
<tr th:each="prod : ${prods}" th:class="${prodStat.odd}? 'odd'">
<td th:text="${prod.name}">Onions</td>
<td th:text="${prod.price}">2.41</td>
...
</tr>
Run Code Online (Sandbox Code Playgroud)
它<tr>在每次迭代中生成一个,这在这种情况下是完美的.但是在我的情况下,我不需要外部标签(这里<tr>).
我的用例是以<bookmark>递归方式生成标记,没有其他标记包含,<bookmark>标记必须包含名称和href属性.
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<body>
<div th:fragment="locationBookmark(location)">
<bookmark th:each="map : ${location.subMaps}">
<bookmark th:name="${map.name}"
th:href="'#'+${map.id}" th:include=":: locationBookmark(${map})">
</bookmark>
</bookmark>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
包括方面:
<bookmark th:include="bookmark : locationBookmark(${rootLocation})"/>
Run Code Online (Sandbox Code Playgroud)
非常感谢.
我的实体有一个mapOrder字段,我希望自动增加,如下所示:
@Entity
public class Map{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(columnDefinition = "serial")
private Long mapOrder;
//.......
}
Run Code Online (Sandbox Code Playgroud)
生成的sql似乎很好:
CREATE TABLE map
(
id bigserial NOT NULL,
map_order serial NOT NULL,
...
)
Run Code Online (Sandbox Code Playgroud)
但是当我使用Spring Data JPA的存储库保存它时,如下所示:
Map m=new Map();
repo.save(m);
Run Code Online (Sandbox Code Playgroud)
会给我例外的:
Caused by: org.postgresql.util.PSQLException: ERROR: null value in column "map_order" violates not-null constraint
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
我有一个类型为 TYPE_4BYTE_ABGR 的字节数组,我知道它的宽度和高度,我想将其更改为 BufferedImage,有什么想法吗?
我的Nginx安装并运行,下面是配置/etc/nginx/nginx.conf,我想将所有内容转发/api/*到我的tomcat服务器,它运行在同一台服务器端口9100(类型http://myhost:9100/api/apps工作),否则,在'/ usr/share/nginx下提供静态文件/ HTML".现在我输入http://myhost/api/apps404.这里的问题是什么?
upstream myserver {
server localhost:9100 weight=1;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location ^~ /api/ {
proxy_pass http://myserver/;
}
location / {
}
}
Run Code Online (Sandbox Code Playgroud)