我对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";
}
StartupApplication:
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
答案 0 :(得分:2)
您的WelcomeController
是rest控制器,使其成为带有@Controller
注释的普通控制器,如本示例所示。
https://medium.com/@milansavaliyaz/spring-boot-hello-world-example-with-jsp-view-7ffed2ae931d