问题错误 404 jsp 未找到项目 spring 引导和 jboss
problem error 404 jsp not found project spring boot and jboss
我的jsp映射有问题我有错误404。我尝试使用客户端-服务器Jboss(我没有选择)。我已经尝试使用 springbootapplication 或 jboss 启动。当我开始使用 springboot 应用程序时,应用程序不起作用但它启动了 jboss 我可以访问在线页面 8080 主页 jboss
控制器公式
@Controller
public class RequestController {
Logger logger = Logger.getLogger("test log 1");
@Autowired
RddRepository rddRepository;
@GetMapping("/formulaire")
public String showFormulaire(Model model) {
model.addAttribute("formulaire", new Formulaire());
logger.info("test appel jsp requeteform");
return "formulaire";
}
@PostMapping("/requeteFormulaire")
public String save(@Valid Formulaire formulaire, BindingResult bindingResult) {
RddRepository.save(formulaire);
return "requeteFormulaire";
}
formulaire.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Formulaire Requete</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<div class="col-md-offset-2 col-md-7">
<h2 class="text-center">Formulaire jeu test</h2>
<div class="panel panel-info">
<div class="panel-heading">
<div class="panel-title">Formulaire</div>
</div>
<div class="panel-body">
<form:form action="/save" Class="form-horizontal">
<div class="form-group">
<label for="identifiant" class="col-md-3 control-label">code compte</label>
<div class="col-md-9">
<form:input path="identifiant" maxlength="9" Class="form-control" />
</div>
</div>
<div class="form-group">
<!-- Button -->
<div class="col-md-offset-3 col-md-9">
<form:button type="submit" value="Save" Class="btn btn-primary">Creer</form:button>
</div>
</div>
</form:form>
</div>
</div>
</div>
</div>
</body>
</html>
application.propertises
server.port=8080
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc8</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>2.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
</dependencies>
@SpringBootApplication
public class RequeteBddJeuTestApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(RequeteBddJeuTestApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(RequeteBddJeuTestApplication.class, args);
}
}
直接使用 .jsp
文件名更改您的 return 语句。
即
return "formulaire";
return "requeteFormulaire";
Sprint MVC 将自动查找属性文件中给定的 prefix/suffix 路径。
我的jsp映射有问题我有错误404。我尝试使用客户端-服务器Jboss(我没有选择)。我已经尝试使用 springbootapplication 或 jboss 启动。当我开始使用 springboot 应用程序时,应用程序不起作用但它启动了 jboss 我可以访问在线页面 8080 主页 jboss
控制器公式
@Controller
public class RequestController {
Logger logger = Logger.getLogger("test log 1");
@Autowired
RddRepository rddRepository;
@GetMapping("/formulaire")
public String showFormulaire(Model model) {
model.addAttribute("formulaire", new Formulaire());
logger.info("test appel jsp requeteform");
return "formulaire";
}
@PostMapping("/requeteFormulaire")
public String save(@Valid Formulaire formulaire, BindingResult bindingResult) {
RddRepository.save(formulaire);
return "requeteFormulaire";
}
formulaire.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Formulaire Requete</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</head>
<body>
<div class="container">
<div class="col-md-offset-2 col-md-7">
<h2 class="text-center">Formulaire jeu test</h2>
<div class="panel panel-info">
<div class="panel-heading">
<div class="panel-title">Formulaire</div>
</div>
<div class="panel-body">
<form:form action="/save" Class="form-horizontal">
<div class="form-group">
<label for="identifiant" class="col-md-3 control-label">code compte</label>
<div class="col-md-9">
<form:input path="identifiant" maxlength="9" Class="form-control" />
</div>
</div>
<div class="form-group">
<!-- Button -->
<div class="col-md-offset-3 col-md-9">
<form:button type="submit" value="Save" Class="btn btn-primary">Creer</form:button>
</div>
</div>
</form:form>
</div>
</div>
</div>
</div>
</body>
</html>
application.propertises
server.port=8080
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.jsp
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.oracle.ojdbc</groupId>
<artifactId>ojdbc8</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api -->
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>javax.servlet.jsp-api</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>2.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
</dependencies>
@SpringBootApplication
public class RequeteBddJeuTestApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(RequeteBddJeuTestApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(RequeteBddJeuTestApplication.class, args);
}
}
直接使用 .jsp
文件名更改您的 return 语句。
即
return "formulaire";
return "requeteFormulaire";
Sprint MVC 将自动查找属性文件中给定的 prefix/suffix 路径。