小编Jav*_*adi的帖子

如何将Spring控制器映射到他们的百万美元视图(intellij14)

我正在尝试配置spring boot thymeleaf和intellij,并且大部分已经将它钉在了它上面,但我似乎无法将控制器与其视图链接,因为intellij恼人地继续显示以下消息,并自动完成系统不管用:

Cannot Resolve 'varName'
Run Code Online (Sandbox Code Playgroud)

我的控制器看起来像这个"main/java /..../ controller.java"

@Controller
public class CardsController {

    @RequestMapping(value="/card/{id}",method = RequestMethod.GET)
    public String viewCardAction(@PathVariable("id") Card card,Model model){
        model.addAttribute("card",card);
        return "cards/view";
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的模型视图"main/resources/cards/view/cards/view":

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head lang="en">
    <meta charset="UTF-8"/>
    <title th:text="${card.name}"></title> <!-- this line shows the message -->
</head>
<body>
    <div th:text="${card.name}"></div> <!-- this line shows the message -->
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

是intelij,仍然没有为此工作,或者我错过了一些配置

注意:它工作和编译,只是想启用自动完成

spring spring-mvc intellij-idea thymeleaf spring-boot

12
推荐指数
2
解决办法
7959
查看次数