Spring启动多个控制器并扩展url

Spring启动多个控制器并扩展url,spring,thymeleaf,Spring,Thymeleaf,这是控制器1: @Controller @RequestMapping("/clusters") public class ClusterController { @Autowired private ClusterService clusterService; @RequestMapping(method = RequestMethod.GET) public String getAllClusters(Model model){ List

这是控制器1:

@Controller
@RequestMapping("/clusters")
public class ClusterController {

    @Autowired
    private ClusterService clusterService;

    @RequestMapping(method = RequestMethod.GET)
    public String getAllClusters(Model model){

        List<Cluster> clusters = this.clusterService.getAllClusters();
        model.addAttribute("clusters", clusters);

        return "clusters";
    }

    @RequestMapping(value = "/clusterInfo", method = RequestMethod.GET)
    public String getCluster(@RequestParam("id") Integer id, Model model){
        Cluster cluster = this.clusterService.findClusterById(id);
        model.addAttribute("cluster", cluster);

        return "testcluster";
    }
首先,我看到所有集群。之后,我可以单击站点上的按钮查看单个集群(控制器1中的方法2)

当我看到一个单独的集群时,我想点击一个按钮来查看链接到该集群的需求。其方法在控制器2中

从控制器1到控制器2时,我希望有以下url路径

这是我用来从url 2转到url 3的按钮。 更多

它不起作用,给了我一个错误。我的问题是,如何使用指定的url路径从控制器1转到控制器2,并在控制器2中检索id=1


这是我的第一个项目,所以我对Spring Boot和Thymeleaf不太了解。

标记查询字符串参数的开始,并且根据URI RFC标准,您不能在查询字符串参数之后指定路径。 我建议将URI改为:

http://localhost:8080/clusters/<clusterId>/clusterInfo
Ex: http://localhost:8080/clusters/1/clusterInfo
http://localhost:8080/clusters//clusterInfo
前任:http://localhost:8080/clusters/1/clusterInfo

http://localhost:8080/clusters//requeriments
前任:http://localhost:8080/clusters/1/requirements
http://localhost:8080/clusters/<clusterId>/clusterInfo
Ex: http://localhost:8080/clusters/1/clusterInfo
http://localhost:8080/clusters/<clusterId>/requeriments
Ex: http://localhost:8080/clusters/1/requirements