小编Jul*_*uly的帖子

Thymeleaf:如何在使用th时排除外部标签:每个?

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)

非常感谢.

java template-engine thymeleaf

12
推荐指数
1
解决办法
7835
查看次数

使用postgresql在串行列上的Spring Data JPA"列xxx中的空值违反非空约束"

我的实体有一个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)

有任何想法吗?

java postgresql hibernate jpa spring-data-jpa

8
推荐指数
2
解决办法
7874
查看次数

将数据类型为 TYPE_4BYTE_ABGR 的字节数组转换为 BufferedImage

我有一个类型为 TYPE_4BYTE_ABGR 的字节数组,我知道它的宽度和高度,我想将其更改为 BufferedImage,有什么想法吗?

java bufferedimage

1
推荐指数
1
解决办法
1851
查看次数

Nginx反向代理返回404

我的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)

nginx

1
推荐指数
1
解决办法
7744
查看次数