[英]IntelliJ IDEA - SpringBoot project / cannot find declaration to go to
I am fairly new to Java and Spring and I have troubles with writing a simple application.我是 Java 和 Spring 的新手,我在编写一个简单的应用程序时遇到了麻烦。
Thing is, IntelliJ does not see my.jsp files that are in the project.问题是,IntelliJ 看不到项目中的 my.jsp 文件。 The application works, but I am not getting help from IntelliJ.
该应用程序有效,但我没有从 IntelliJ 获得帮助。 I also can't use model I created in my HomeController class in my homepage.jsp with forms and modelAttribute, as it becomes red and does not support me writing the code.
我也不能使用我在主页的 HomeController class 中创建的 model。jsp 和 forms 和 modelAttribute,因为它变成红色并且不支持我编写代码。
.jsp files are in webapp/WEB-INF/jsp/ .jsp 文件在 webapp/WEB-INF/jsp/
I have application.properties file with:我有 application.properties 文件:
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
Here are my files:这是我的文件:
HomeController.java家庭控制器.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";
}
}
Credentials.java凭据.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;
}
} }
homepage.jsp主页.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>
Thanks a lot for help!非常感谢您的帮助!
Maybe you have something wrong with your web-inf directory mark. 也许您的web-inf目录标记有问题。 Right click on webapp -> mark directory as -> sources root
右键单击webapp->将目录标记为-> Sources root
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.