- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我尝试制作一个简单的 Spring Boot Web 应用程序:
POM:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
主类:
@ComponentScan(basePackages={"controller"})
@Import(MvcConfig.class)
@EnableAutoConfiguration
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Controller :
@Controller
@RequestMapping("/home")
public class HomeController {
@RequestMapping("/hello")
@ResponseBody
public String hello(){
return "hello";
}
@RequestMapping("/helloView")
public String helloView(){
return "homeView";
}
}
也在src/main
下我得到了
src
-main
-resources
applicaion.properties
-webapp
-WEB-INF
-jsp
-homeView.jsp
在 application.properties 中我得到:
spring.view.prefix: /WEB-INF/jsp/
spring.view.suffix: .jsp
rest 端点/home/hello
工作,但另一个无法打开jsp。在我得到的日志中
Looking up handler method for path /WEB-INF/jsp/homeView.jsp
Did not find handler method for [/WEB-INF/jsp/homeView.jsp]
我应该将 View 放在哪里以便应用可以找到它们?
最佳答案
感谢geoand的回答我补充了
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
到 pom,它成功了。
关于java - Spring Boot Web starter View 位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22731225/
有什么区别: spring-boot-starter-web spring-boot-starter-web-services spring-boot-starter-jersey? 文档说 Star
我注意到 Spring Boot Sample Data Redis 声明了以下依赖项: org.springframework.boot spring-boot-starter
我正在观看有关 Spring Boot 的视频教程(来自 javabrains.io)。示例项目的 pom 文件包含一个父 block ,其 groupId 为 org.springframework
我正在努力尝试使用 spring boot (1.1.6.RELEASE)、gradle (2.1) 和 Java 1.8 来练习一些技术。所以我们正在考虑支持一些旧式 SOAP Web 服务调用以及
我正在尝试学习 Spring Boot,但我注意到有两种选择。 spring-boot-starter-web - 根据文档,它支持全栈 Web 开发,包括 Tomcat 和 web-mvc spri
我正在尝试在 IntellIJ 中开发一个基于 Spring Boot 的示例应用程序。所以我使用了 spring Initialzr 方法,并在设置过程中进行了默认选择。我最终得到的 pom.xml
是否可以在一个应用程序中同时使用这两个启动器? 我想将 CSV 文件中的记录加载到数据库表中。 Spring Batch 表存储在不同的数据库中,因此我假设我需要使用 JTA 来处理事务。 每当我将
我有一个微服务应用程序,在我包含的 JAR 依赖项之一中 org.springframework.boot spring-boot-starter-webflux 所以我可以使用响
当我开始学习spring-webflux时,我对这个组件有疑问。 我构建了一个简单的项目,使用maven来管理它。我添加了与 spring-boot-starter-web 和 spring-boot
我已经使用 optaplanner-spring-boot-starter 作为依赖项开发了一个完整的工作 spring boot 项目,用于任务分配,但要求是使用 kie-server-spring
当我开始学习spring-webflux时,我对这个组件有疑问。 我构建了一个简单的项目,使用 maven 来管理它。我添加了与 spring-boot-starter-web 和 spring-bo
我尝试了 spring-boot-starter-actuator,默认指令,在 pom 中添加到 spring boot 项目,它运行没有任何问题。 一旦我添加 spring-boot-starte
我当时尝试包含上述依赖项之一,但找不到任何区别: spring boot starter web:我可以看到 Flux 和 Mono 类并制作一个响应式(Reactive)休息 Controller
我们将 spring-cloud-starter-hystrix 与 spring-cloud-starter-archaius 一起使用,一旦 war 取消部署,我们将无法停止 archaius 的
我刚刚开始使用 OAuth2 学习 Spring Security,我想为我的微服务 Restful Api 创建授权服务器和资源服务器。但是我不知道从哪个依赖项开始,因为我找到了其中的一些。我使用
我正在使用 spring-boot-starter-jersey 和 spring-boot-starter-tomcat (v. 1.5.2) 和作为因此,我宁愿不添加 spring-boot-st
我正在尝试对微服务的端点实现基本身份验证。所以我使用了 spring-boot-starter-security。但我注意到 spring-boot-starter-security 不适用于 spr
我想使用 spring-boot-starter,但这意味着我必须使用“spring-boot-starter-parent”pom 而不能使用公司广泛使用的根 pom。 Spring-boot-st
目前我们正在使用 com.graphql-java-kickstart graphql-spring-boot-starter ${graph
我是 Spring Cloud 的新手,两者之间的确切区别是什么spring-cloud-starter-eureka-server和 spring-cloud-starter-netflix-eur
我是一名优秀的程序员,十分优秀!