![](/img/trans.png)
[英]"Cannot find declaration to go" protos declaration in IntelliJ IDEA
[英]IntelliJ IDEA - SpringBoot project / cannot find declaration to go to
我是 Java 和 Spring 的新手,我在編寫一個簡單的應用程序時遇到了麻煩。
問題是,IntelliJ 看不到項目中的 my.jsp 文件。 該應用程序有效,但我沒有從 IntelliJ 獲得幫助。 我也不能使用我在主頁的 HomeController class 中創建的 model。jsp 和 forms 和 modelAttribute,因為它變成紅色並且不支持我編寫代碼。
.jsp 文件在 webapp/WEB-INF/jsp/
我有 application.properties 文件:
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
這是我的文件:
家庭控制器.java
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class HomeController {
@RequestMapping("/")
public String hello(Model theModel){
Credentials theCredentials = new Credentials();
theModel.addAttribute("credentials", theCredentials);
return "homepage";
}
}
憑據.java
public class Credentials {
private String username;
private String password;
public Credentials() {
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
主頁.jsp
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Homepage</title>
</head>
<body>
Welcome to the virtual deanery!!!
<br><br>
Please log in as Student or Teacher to continue:
<br><br>
<form:form modelAttribute="credentials">
<%--credentials are not found--%>
<%--somecode--%>
</form:form>
</body>
</html>
非常感謝您的幫助!
也許您的web-inf目錄標記有問題。 右鍵單擊webapp->將目錄標記為-> Sources root
需要添加 spring Facet 和這樣的彈簧配置
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.