나는 thymeleaf가있는 간단한 Springboot 응용 프로그램을 가지고 있습니다. src/main/resources/templates/pacientes 아래에 formPaciente.html 파일을 만들고 URL을 매핑하는 컨트롤러를 만들었지 만 액세스하려고 할 때 404 오류가 발생했습니다. index.html에 대해 동일한 작업을 수행했습니다.Error 404 RequestMapping을 사용하여 html 페이지에 액세스하려고 시도했습니다.
프로젝트 LS -R
ls -R
.:
main test
./main:
java resources
./main/java:
com Controllers models
./main/java/com:
Laudosapp
./main/java/com/Laudosapp:
laudosapp
./main/java/com/Laudosapp/laudosapp:
indexController.java LaudosappApplication.java
./main/java/Controllers:
PacienteController.java
./main/java/models:
Paciente.java
./main/resources:
application.properties static templates
./main/resources/static:
./main/resources/templates:
index.html pacientes
./main/resources/templates/pacientes:
formPaciente.html
./test:
java
./test/java:
com
./test/java/com:
Laudosapp
./test/java/com/Laudosapp:
laudosapp
./test/java/com/Laudosapp/laudosapp:
LaudosappApplicationTests.java
formPaciente.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1> Cadastro de pacientes</h1>
<form method="post">
<input type=""text" value="" name="pacientenome"/>
<input type=""text" value="" name="pacientesexo"/>
<input type=""text" value="" name="pacientedatanasc"/>
<input type=""text" value="" name="pacientedataexame"/>
<input type=""text" value="" name="medicosolicitante"/>
<input type=""text" value="" name="specmedica"/>
<input type=""text" value="" name="hda"/>
<input type=""text" value="" name="pacienteconvenio"/>
<button type="submit">Salvar</button>
</form>
</body>
</html>
컨트롤러 당신이 .HTM 페이지에서 개체를 전송하지만 수신되지 않은 것으로 보인다
package Controllers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class PacienteController {
@RequestMapping("/cadastrarpaciente")
public String form(){
return "pacientes/formPaciente";
}
}