Reputation: 67
I am getting "welcome" on hit of localohst: instead of my welcome.jsp
Here is my controller:
@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
Upvotes: 0
Views: 49
Reputation: 56
Your WelcomeController
is rest controller make it normal controller with @Controller
annotation as shown in this example.
https://medium.com/@milansavaliyaz/spring-boot-hello-world-example-with-jsp-view-7ffed2ae931d
Upvotes: 2