未找到Java Spring框架资源IntelliJ
在尝试制作这个java/SpringWeb应用程序时,我遇到了一个非常令人困惑的错误。它似乎找不到正确的资源,并在应用程序运行时显示错误页面 在IntelliJ中,控制台根本不记录错误,因此很难跟踪出错的位置 因此,我甚至删除了我的整个项目,并决定遵循一个在线教程的确切内容。我仍然得到相同的运行时错误!我很困惑 这是我的目录的外观: 这是我的控制器的代码:未找到Java Spring框架资源IntelliJ,java,spring-boot,intellij-idea,Java,Spring Boot,Intellij Idea,在尝试制作这个java/SpringWeb应用程序时,我遇到了一个非常令人困惑的错误。它似乎找不到正确的资源,并在应用程序运行时显示错误页面 在IntelliJ中,控制台根本不记录错误,因此很难跟踪出错的位置 因此,我甚至删除了我的整个项目,并决定遵循一个在线教程的确切内容。我仍然得到相同的运行时错误!我很困惑 这是我的目录的外观: 这是我的控制器的代码: package sheridan.assaf.assignment1.demo.Controller; import org.sprin
package sheridan.assaf.assignment1.demo.Controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import sheridan.assaf.assignment1.demo.Model.Greeting;
@Controller
public class GreetingController {
@GetMapping("/greeting")
public String greetingForm(Model model) {
model.addAttribute("greeting", new Greeting());
return "greeting";
}
@PostMapping("/greeting")
public String greetingSubmit(@ModelAttribute Greeting greeting) {
return "result";
}
}
这是我的问候语课程的代码:
package sheridan.assaf.assignment1.demo.Model;
public class Greeting {
private long id;
private String content;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
}
这是my greeting.html模板的代码:
<!DOCTYPE HTML>
<html xmlns:th="https://www.thymeleaf.org">
<head>
<title>Getting Started: Handling Form Submission</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Form</h1>
<form action="#" th:action="@{/greeting}" th:object="${greeting}" method="post">
<p>Id: <input type="text" th:field="*{id}" /></p>
<p>Message: <input type="text" th:field="*{content}" /></p>
<p><input type="submit" value="Submit" /> <input type="reset" value="Reset" /></p>
</form>
</body>
</html>
入门:处理表单提交
形式
身份证:
信息:
这是result.html的代码:
<!DOCTYPE HTML>
<html xmlns:th="https://www.thymeleaf.org">
<head>
<title>Getting Started: Handling Form Submission</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<h1>Result</h1>
<p th:text="'id: ' + ${greeting.id}" />
<p th:text="'content: ' + ${greeting.content}" />
<a href="/greeting">Submit another message</a>
</body>
</html>
入门:处理表单提交
结果
需要注意的是:在result.html中,greeting.id和greeting.content在IntelliJ中用红色下划线表示“无法解决”错误,但这似乎并不意味着什么,因为我运行了一个我的教授制作的web应用程序作为示例,他也有同样的错误,他的运行很好
以下是错误消息:
请共享。如果您将代码发布到github并在此处发布链接,效果会更好。另外,还不清楚您正在调用什么URL。pom.xml文件的内容也很好看到。