【发布时间】:2018-08-16 15:28:15
【问题描述】:
点击 localohst: 而不是我的welcome.jsp,我得到“欢迎”
这是我的控制器:
@RestController
public class WelcomeController {
// inject via application.properties
@Value("${welcome.message:test}")
private String message = "Hello World";
@RequestMapping("/")
public String welcome(Map<String, Object> model) {
model.put("message", this.message);
return "welcome";
}
启动应用程序:
public class SpringBootWebApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(SpringBootWebApplication.class);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(SpringBootWebApplication.class, args);
}
application.properties:
spring.mvc.view.prefix:/WEB-INF/jsp/
spring.mvc.view.suffix: .jsp
【问题讨论】:
-
您使用的是嵌入式tomcat还是其他服务器?
-
我正在使用嵌入式 tomcat
org.springframework.boot spring-boot-starter-tomcat 提供
标签: java spring spring-mvc jsp spring-boot