小编Mac*_*iaz的帖子

@Primary与@Autowired与@Qualifier注释之间的区别

所以,如果我理解正确,如果有多个候选者,两者都是确定哪个bean自动装配的方法.那究竟是什么区别呢?

java spring annotations

17
推荐指数
3
解决办法
2万
查看次数

如何使用新标签复制 docker 镜像?

假设我有一张带有标签的图像:latest
我想在我的电脑上复制该图像,然后给它另一个标签,例如:1.4.2

我不想构建图像,只需复制并重新标记它。

docker

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

Spring MVC - Thymeleaf 表单与数组列表绑定

在特定的视图中,我确实有一个可扩展的员工列表。每个员工都有 2 个字段,即hoursWorked& advancePayments。单击 1 个按钮,我想发布整个表格。为了实现此目的,我将一个列表发送到包含多个 POJO(基于员工数量)的视图。

添加到列表中的 POJO 如下所示:

@Setter
@Getter
@NoArgsConstructor
public class WorkdayCommand {

    private Long employeeId;
    private Integer hoursWorked;
    private Integer advancePayment;
}
Run Code Online (Sandbox Code Playgroud)

在控制器中,我确实有一行将列表添加到模型中:

model.addAttribute("workdayCommands", employeeService.getListOfWorkdayCommandsWithIds());
Run Code Online (Sandbox Code Playgroud)

以及形成实际列表的方法:

public List<WorkdayCommand> getListOfWorkdayCommandsWithIds(){

    List<WorkdayCommand> listOfCommands = new ArrayList<>();
    List<Long> listOfIds = employeeRepository.getListOfIds();

    for(int i = 0; i < employeeRepository.getNumberOfEmployees(); i++){

        WorkdayCommand workdayCommand = new WorkdayCommand();
        workdayCommand.setEmployeeId(listOfIds.get(i));
        listOfCommands.add(workdayCommand);
    }

    return listOfCommands;
}
Run Code Online (Sandbox Code Playgroud)

现在我的观点有问题:

<div class="table-responsive" th:if="${not #lists.isEmpty(employees)}">
    <form th:object="${workdayCommands}" th:action="@{/addworkday}">
         some table headers...
         <tr th:each="employee : ${employees}"> …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc thymeleaf

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

不能在类上使用 lombok @NoArgsConstructor

我使用 Jackson 作为 Json 解析器,但出现错误:

No suitable constructor found for type ~ can not instantiate from JSON object
Run Code Online (Sandbox Code Playgroud)

所以我尝试添加@NoArgsConstructor,但现在我得到了这个:

constructor AccountItem in class AccountItem cannot be applied to given types
Run Code Online (Sandbox Code Playgroud)

这是我的课:

@Getter
@Builder
public class AccountItem {

/**
 * Accounti dentifier
 */
private Long accountId;

/**
 * Account name
 */
private String accountName;

/**
 * Account priority
 */
private int accountPriority;
}
Run Code Online (Sandbox Code Playgroud)

可能是什么原因?

java jackson lombok

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

自定义 .css 文件不适用于 Thymeleaf 和 Spring MVC

所以,我花了像最后一个小时试图解决它,但我只是无法获得自定义 .css 文件与Spring 5 中的html 文件链接。我正在使用 Thymeleaf、BootstrapjQuery进行前端工作。我正在使用 Intellij 社区版。

我的文件层次结构如下所示:

java
    project_files
resources
    static
        css
          main.css
    templates
        main.html
Run Code Online (Sandbox Code Playgroud)

我有一行main.html

<link rel="stylesheet" type="text/css" th:href="@{/css/main.css}" href="../../css/main.css"/>
Run Code Online (Sandbox Code Playgroud)

这应该将我的样式与 .html 文件链接起来。有什么问题?

css spring spring-mvc thymeleaf bootstrap-4

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

array[++variable] 代表什么?

示例代码在这里:

static class stack 
{
    int top=-1;
    char items[] = new char[100];

    void push(char x) 
    {
        if (top == 99)
            System.out.println("Stack full");
        else
            items[++top] = x;
    }
}
Run Code Online (Sandbox Code Playgroud)

当 items[++top] 出现时到底发生了什么?

java arrays iteration

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